smif.convert.area module

Handles conversion between the sets of regions used in the SosModel

Summary

Classes:

NamedShape
RegionRegister Holds the sets of regions used by the SectorModels and provides conversion between data values relating to compatible sets of regions.
RegionSet Hold a set of regions, spatially indexed for ease of lookup when constructing conversion matrices.

Functions:

get_register Return single copy of RegionRegister

Reference

class smif.convert.area.NamedShape(name, shape)

Bases: tuple

name

Alias for field number 0

shape

Alias for field number 1

class smif.convert.area.RegionSet(set_name, fiona_shape_iter)[source]

Bases: smif.convert.register.ResolutionSet

Hold a set of regions, spatially indexed for ease of lookup when constructing conversion matrices.

Parameters:
  • set_name (str) – Name to use as identifier for this set of regions
  • fiona_shape_iter (iterable) – Iterable (probably a list or a reader handle) of fiona feature records e.g. the ‘features’ entry of a GeoJSON collection
data
get_entry_names()[source]

Get the names of the entries in the ResolutionSet

Returns:The set of names which identify each entry in the ResolutionSet
Return type:set
as_features()[source]

Get the regions as a list of feature dictionaries

Returns:A list of GeoJSON-style dicts
Return type:list
centroids_as_features()[source]

Get the region centroids as a list of feature dictionaries

Returns:A list of GeoJSON-style dicts, with Point features corresponding to region centroids
Return type:list
intersection(to_entry)[source]

Return the set of regions intersecting with the bounds of to_entry

get_proportion(from_idx, entry_b)[source]

Calculate the proportion of shape a that intersects with shape b

static get_bounds()[source]

Implement this helper method to return bounds from an entry in the register

Parameters:entry – An entry from a ResolutionSet
Returns:The bounds of the entry
Return type:bounds
coverage
class smif.convert.area.RegionRegister[source]

Bases: smif.convert.register.NDimensionalRegister

Holds the sets of regions used by the SectorModels and provides conversion between data values relating to compatible sets of regions.

Notes

The argument axis=0 refers to the dimension of the data array that is associated with the regions dimension.

smif.convert.area.get_register()[source]

Return single copy of RegionRegister