bw2regional.utils
Module Contents
Functions
|
|
Shortcut to create Intersection object with no data |
|
|
|
|
Filter a sparse matrix, either excluding or taking only the columns in |
Include only valid Fiona keywords for opening a feature collection |
|
|
Filter a sparse matrix, either excluding or taking only the rows in |
|
|
|
|
|
Get kind of spatial dataset at filepath. |
|
Return SHA256 hash for a topo- or geocollection. |
|
Import data from a vector geospatial dataset into a |
Reset all bw2regional data and metadata |
|
- bw2regional.utils.create_empty_intersection(name)[source]
Shortcut to create Intersection object with no data
- bw2regional.utils.filter_columns(matrix, col_indices, exclude=True)[source]
Filter a sparse matrix, either excluding or taking only the columns in
col_indices.matrix: A Scipy sparse matrix.col_indices: An iterable of integer column indicesexclude: Boolean. If true, exclude rows inrow_indices. Otherwise, include only rows inrow_indices.
Returns a sparse matrix.
- bw2regional.utils.filter_fiona_metadata(dct)[source]
Include only valid Fiona keywords for opening a feature collection
- bw2regional.utils.filter_rows(matrix, row_indices, exclude=True)[source]
Filter a sparse matrix, either excluding or taking only the rows in
row_indices.matrix: A Scipy sparse matrix.row_indices: An iterable of integer row indicesexclude: Boolean. If true, exclude rows inrow_indices. Otherwise, include only rows inrow_indices.
Returns a sparse matrix.
- bw2regional.utils.get_spatial_dataset_kind(filepath)[source]
Get kind of spatial dataset at filepath.
Returns one of “vector”, “raster”, None.
- bw2regional.utils.hash_collection(name)[source]
Return SHA256 hash for a topo- or geocollection.
Prefers topocollection if available.
- bw2regional.utils.import_regionalized_cfs(geocollection, method_tuple, mapping, scaling_factor=1, global_cfs=None, nan_value=None)[source]
Import data from a vector geospatial dataset into a
Method.A
Methodcan have both site-generic and regionalized characterization factors.The
mappingdefines which field (vector) maps to which biosphere flows. Some geocollections may only define regionalized chracterization factors for a single biosphere flow, but it is much more common to have each field or band map to multiple biosphere flows. Therefore, mapping should be defined as:{ field name (str): [list of biosphere flows (tuples)] }
- Parameters:
geocollection (*) – A
geocollectionname.method_tuple (*) – A method tuple.
mapping (*) – Mapping from fields or bands to biosphere flows. See above.
scaling_factor (*) – Optional. Rescale the values in the spatial data source.
global_cfs (*) – An optional list of CFs to add when writing the method.
nan_value (*) – Sentinel value for missing values if
NaNis not used directly.