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 raster 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
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 those that fall inside them (done)
As an aside, it is important to carry all original attributes from the exposure data (in case it is vector data) set to the impact layer. This should also be done early in the existing implementation to avoid impact functions having to do it.
Made raster vector interpolation carry all attributes across. This cl…
…oses issue #101
Interpolation from Raster to Vector now carries the original attributes across. This doesn't close the ticket, but it is good progress. This was done in commit e2f4986
Kristy and Ole decided to name this general function
assign_hazard_level_to_exposure(hazard=...., exposure=..., attribute_name=...., layer_name=....)
with same functionality already exposed by the underlying interpolation functions.
Made a very good start on issue #101
Change all occurrences of the form H.interpolate(E, ...) with assign_hazard_level_to_exposure(hazard=H, exposure=E, ...
in tests and impact functions.
Replaced occurences of .interpolate() with assign_hazar_levels_to_exp…
…osure_data as per issue #101
Work on generalising multy type interpolation as per issue #101
Cleaned up and marked one thing as outstanding for when we retire the…
… H.interpolate(E) form in all impact functions. Issue #101
Cleaned up in interpolation module and verified all tests and standar…
…ds pass. This closes #101