Generalise interpolation function #101

Closed
uniomni opened this Issue Feb 24, 2012 · 4 comments

1 participant

@uniomni

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
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 those that fall inside them (done)
@uniomni uniomni was assigned Feb 24, 2012
@uniomni

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.

@uniomni

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

@uniomni

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.

@uniomni

Change all occurrences of the form H.interpolate(E, ...) with assign_hazard_level_to_exposure(hazard=H, exposure=E, ...
in tests and impact functions.

@uniomni uniomni added a commit that referenced this issue Sep 1, 2012
@uniomni uniomni Replaced occurences of .interpolate() with assign_hazar_levels_to_exp…
…osure_data as per issue #101
7d88913
@uniomni uniomni added a commit that referenced this issue Sep 1, 2012
@uniomni uniomni Cleaned up and marked one thing as outstanding for when we retire the…
… H.interpolate(E) form in all impact functions. Issue #101
9c5c86f
@uniomni uniomni closed this in 4ce9a64 Sep 3, 2012
@uniomni uniomni removed their assignment Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment