### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe »
- Package::safe.engine »

# Module: safe.engine.interpolation

Interpolation from hazard to exposure layers.

Provides interpolation functionality to assign values from one layer instance to another irrespective of layer types.

`safe.engine.interpolation.``assign_hazard_values_to_exposure_data`(hazard, exposure, layer_name=None, attribute_name=None, mode='linear')

  Assign hazard values to exposure data

  This is the high level wrapper around interpolation functions for different combinations of data types.

  Args:

    - hazard: Layer representing the hazard levels

    - exposure: Layer representing the exposure data

    - layer_name: Optional name of returned layer.

        If None (default) the name of the exposure layer is used for the returned layer.

    - attribute_name:

        If hazard layer is of type raster, this is the name for new attribute in the result containing the hazard level. If None (default) the name of hazard is used

        If hazard layer is of type vector, it is the name of the attribute to transfer from the hazard layer into the result. If None (default) all attributes are transferred.

    > - mode:

    >     Interpolation mode for raster to point interpolation only

  Returns:
    Layer representing the exposure data with hazard levels assigned.
  Raises:
    Underlying exceptions are propagated

  Note:

  > Admissible combinations of input layer types are

  > > Exposure | Raster Polygon Line Point

  > Polygon | Y Y Y Y Raster | Y Y Y Y

  > with the following methodologies used:

  > Polygon-Point: Clip points to polygon and assign polygon attributes
  >   to them.

  > Polygon-Line: * Not Implemented * Polygon-Polygon: * Not Implemented * Polygon-Raster: Convert raster to points, clip to polygon,

  > > assign values and return point data

  > Raster-Point: Bilinear (or constant) interpolation as currently
  >   implemented

  > Raster-Line: * Not Implemented * Raster-Polygon: Calculate centroids and use Raster - Point algorithm Raster-Raster: Exposure raster is returned as is

  > The data type of the resulting layer depends on the combination of input types as follows:

  > Polygon-Point: Point data Polygon-Line: N/A Polygon-Polygon: N/A Polygon-Raster: Point data Raster-Point: Point data Raster-Line: N/A Raster-Polygon: Polygon data Raster-Raster: Raster data

`safe.engine.interpolation.``check_inputs`(hazard, exposure, layer_name, attribute_name)

  Check inputs and establish default values

  Args:
    - hazard: Hazard layer instance (any type)
    - exposure: Exposure layer instance (any type)
    - layer_name: Name of returned layer or None
    - attribute_name: Name of interpolated attribute or None
  Returns:
    - layer_name
    - attribute_name
  Raises:
    VerificationError

`safe.engine.interpolation.``interpolate_polygon_lines`(source, target, layer_name=None, attribute_name=None)

  Interpolate from polygon vector layer to line vector data

  Args:

    - source: Vector data set (polygon)

    - target: Vector data set (lines)

    - layer_name: Optional name of returned interpolated layer.

        If None the name of target is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of source is used

  Returns:
    Vector data set of lines inside polygons

      Attributes are combined from polygon they fall into and line that was clipped.

      Lines not in any polygon are ignored.

`safe.engine.interpolation.``interpolate_polygon_points`(source, target, layer_name=None, attribute_name=None)

  Interpolate from polygon vector layer to point vector data

  Args:

    - source: Vector data set (polygon)

    - target: Vector data set (points)

    - layer_name: Optional name of returned interpolated layer.

        If None the name of target is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of source is used

  Output
    I: Vector data set; points located as target with values interpolated from source

`safe.engine.interpolation.``interpolate_polygon_raster`(source, target, layer_name=None, attribute_name=None)

  Interpolate from polygon layer to raster data

  Args

    - source: Polygon data set

    - target: Raster data set

    - layer_name: Optional name of returned interpolated layer.

        If None the name of source is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of layer target is used

  Output
    I: Vector data set; points located as target with
      values interpolated from source
  Note:
    Each point in the resulting dataset will have an attribute ‘polygon_id’ which refers to the polygon it belongs to.

`safe.engine.interpolation.``interpolate_polygon_vector`(source, target, layer_name=None, attribute_name=None)

  Interpolate from polygon vector layer to vector data

  Args:

    - source: Vector data set (polygon)

    - target: Vector data set (points or polygons) - TBA also lines

    - layer_name: Optional name of returned interpolated layer.

        If None the name of target is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of source is used

  Output
    I: Vector data set; points located as target with values interpolated
      from source
  Note:
    If target geometry is polygon, data will be interpolated to its centroids and the output is a point data set.

`safe.engine.interpolation.``interpolate_raster_raster`(source, target)

  Check for alignment and returns target layer as is

`safe.engine.interpolation.``interpolate_raster_vector`(source, target, layer_name=None, attribute_name=None, mode='linear')

  Interpolate from raster layer to vector data

  Args:

    - source: Raster data set (grid)

    - target: Vector data set (points or polygons)

    - layer_name: Optional name of returned interpolated layer.

        If None the name of V is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of R is used

  Returns:
    I: Vector data set; points located as target with values
      interpolated from source

  Note: If target geometry is polygon, data will be interpolated to its centroids and the output is a point data set.

`safe.engine.interpolation.``interpolate_raster_vector_points`(source, target, layer_name=None, attribute_name=None, mode='linear')

  Interpolate from raster layer to point data

  Args:

    - source: Raster data set (grid)

    - target: Vector data set (points)

    - layer_name: Optional name of returned interpolated layer.

        If None the name of target is used for the returned layer.

    - attribute_name: Name for new attribute.

        If None (default) the name of layer source is used

    - mode: ‘linear’ or ‘constant’ - determines whether interpolation

        from grid to points should be bilinear or piecewise constant

  Output
    I: Vector data set; points located as target with values
      interpolated from source

`safe.engine.interpolation.``make_circular_polygon`(centers, radii, attributes=None)

  Create circular polygon in geographic coordinates

  Args:

    centers: list of (longitude, latitude) radii: desired approximate radii in meters (must be

    > monotonically ascending).

    Can be either one number or list of numbers attributes (optional): Attributes for each center

  Returns
    Vector polygon layer representing circle in WGS84

This module forms part of the InaSAFE tool.

### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe »
- Package::safe.engine »