Observation values aggregation over shapes
This module processes layers of data containing geographic coordinates and observed values for a certain parameter (band) and returns records containing an identifier for a geographic shape and the value of the band aggregated over the shape.
- class MultiRecord(values: List[Union[float, NoneType]], prop: str)[source]
- values: List[Optional[float]]
- prop: str
- class StatsCounter[source]
- statistics = 'mean'
- max_mem_used = 0
- classmethod prepare_stats(strategy: RasterizationStrategy, shpfile: str, affine: Affine, layer: Iterable, no_data, is_generator: bool) List [source]
Given a layer, i.e. a slice of a dataframe, and a shapefile returns an iterable of records, containing aggregated values of the observations over the shapes in the shapefile.
- Parameters
- Returns
A list of statistics compute objects
- classmethod process(strategy: RasterizationStrategy, shpfile: str, affine: Affine, layer: Iterable, geography: Geography, no_data=None) Iterable[Record] [source]
Given a layer, i.e. a slice of a dataframe, and a shapefile returns an iterable of records, containing aggregated values of the observations over the shapes in the shapefile.
- Parameters
no_data¶ – Values that is treated as missing value
strategy¶ – Rasterization strategy to be used
shpfile¶ – A path to shapefile to be used
affine¶ – An optional affine transformation to be applied to the coordinates
layer¶ – A slice of dataframe, containing coordinates and values
geography¶ – WHat type of geography is to be used: zip codes or counties
- Returns
An iterable of records, containing an identifier of a certain shape with the aggregated value of the observation for this shape
- classmethod process_layers(strategy: RasterizationStrategy, shpfile: str, affine: Affine, layers: List[Iterable], geography: Geography) Iterable[MultiRecord] [source]
Given a layer, i.e. a slice of a dataframe, and a shapefile returns an iterable of records, containing aggregated values of the observations over the shapes in the shapefile.
- Parameters
strategy¶ – Rasterization strategy to be used
shpfile¶ – A path to shapefile to be used
affine¶ – An optional affine transformation to be applied to the coordinates
layers¶ – A list of slices of dataframe, containing coordinates and values
geography¶ – WHat type of geography is to be used: zip codes or counties
- Returns
An iterable of records, containing an identifier of a certain shape with the aggregated value of the observation for this shape
- classmethod process_layers_return_dict(strategy: RasterizationStrategy, shpfile: str, affine: Affine, layers: List[Iterable], geography: Geography) Dict[str, MultiRecord] [source]
Given a layer, i.e. a slice of a dataframe, and a shapefile returns an iterable of records, containing aggregated values of the observations over the shapes in the shapefile.
- Parameters
strategy¶ – Rasterization strategy to be used
shpfile¶ – A path to shapefile to be used
affine¶ – An optional affine transformation to be applied to the coordinates
layers¶ – A list of slices of dataframe, containing coordinates and values
geography¶ – WHat type of geography is to be used: zip codes or counties
- Returns
A List of records, containing an identifier of a certain shape with the aggregated value of the observation for this shape