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
proportion_of_a_intersecting_b Calculate the proportion of shape a that intersects with shape b

Reference

smif.convert.area.proportion_of_a_intersecting_b(shape_a, shape_b)[source]

Calculate the proportion of shape a that intersects with shape b

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]
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(bounds)[source]

Return the subset of regions intersecting with a bounding box

class smif.convert.area.RegionRegister[source]

Bases: smif.convert.register.Register

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

names

Names of registered region sets

Returns:sets
Return type:list of str
get_entry(name)[source]

Returns the ResolutionSet of name

Parameters:name (str) – The unique identifier of a ResolutionSet in the register
Returns:
Return type:smif.convert.area.RegionSet
register(region_set)[source]

Register a set of regions as a source/target for conversion

convert(data, from_set_name, to_set_name)[source]

Convert a list of data points for a given set of regions to another set of regions.

Parameters:
  • data (numpy.ndarray with dimension regions) –
  • from_set_name (str) –
  • to_set_name (str) –
smif.convert.area.get_register()[source]

Return single copy of RegionRegister