# Generalise interpolation function #101

Closed
opened this Issue Feb 24, 2012 · 4 comments

### 1 participant

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)
```
was assigned Feb 24, 2012

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.

added a commit that referenced this issue May 15, 2012
 uniomni `Made raster vector interpolation carry all attributes across. This cl…` `…oses issue #101` `e2f4986`

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.

added a commit that referenced this issue Aug 31, 2012
 uniomni `Made a very good start on issue #101` `97dcaec`

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

added a commit that referenced this issue Sep 1, 2012
 uniomni `Replaced occurences of .interpolate() with assign_hazar_levels_to_exp…` `…osure_data as per issue #101` `7d88913`
added a commit that referenced this issue Sep 1, 2012
 uniomni `Work on generalising multy type interpolation as per issue #101` `f602fd8`
added a commit that referenced this issue Sep 1, 2012
 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`
added a commit that closed this issue Sep 3, 2012
 uniomni `Cleaned up in interpolation module and verified all tests and standar…` `…ds pass. This closes #101` `4ce9a64`
closed this in `4ce9a64` Sep 3, 2012
removed their assignment Nov 16, 2015