AIFDR/risk_in_a_box — Issue #101: Generalise interpolation function
Author: uniomni
Created: 2012-02-24 03:07:52+00:00
State: open

Currently, we use the idiom

I = H.interpolate(E)

Where H is the hazard layer, E the exposure layer and I a new layer of same type as E with a new attribute derived from H either by interpolation (in case H is raster) or by clipping and tagging in case it is a polygon.

Usually - in case E is a vector layer, we then move all other attributes from E across to I using a loop such as
for key in attribute_names:
result_dict[key] = E.get_data(key, i)

In case E is a raster, we check for alignment and return I = E

I suggest we move to a new paradigm as follows:

If E is vector data:
I = E.get_hazard_level(H)
will assign hazard level attribute to exposure vector data in addition to all existing attributes.

If E is hazard data, it will work is before
I = H (with some checking)

The addmissible combination of data types shall be
(make this an RST table)

E Raster Polygon Line Point
H \

Raster Y Y Y Y
Polygon Y Y Y Y
Line Not Applicable
Point Not Applicable

with the following methodologies used:

Raster - Raster: As currently implemented
Raster - Polygon: Calculate centroids and use Raster - Point
Raster - Line: TBA - maybe use line mid points/ or convert raster to polygon and use Polygon- Line
Raster - Point: Bilinear (or constant) interpolation as currently implemented
Polygon - Raster: Clip raster to polygon (with NaN's to account for points outside and return ???
Polygon - Polygon: Maybe calculate intersections with associated pct area and ???
Polygon - Line: Clip lines to polygon and assign polygon attributes to line segments that fall inside them
Polygon - Point: Clip points to polygon and assign polygon attributes to line segments that fall inside them (done)