onstove.OnStove.add_layer#
- OnStove.add_layer(path: str, layer_type: str, category: str = 'Other', name: str = None, query: str = None, postgres: bool = False, base_layer: bool = False, resample: str = 'nearest', normalization: str = 'MinMax', inverse: bool = False, distance_method: str | None = None, distance_limit: Callable[[ndarray], ndarray] | None = None, window: bool | None = False, rescale: bool = False)#
Adds a new layer (type VectorLayer or RasterLayer) to the DataProcessor class
- Parameters:
- category: str
Category of the layer. This parameter is useful to group the data into logical categories such as “Demographics”, “Resources” and “Infrastructure” or “Demand”, “Supply” and “Others”. These categories are particularly relevant for the
MCA
analysis.- name: str
Name of the dataset.
- path: str
Path to the layer.
- layer_type: str
Layer type, vector or raster.
- query: str, optional
A query string to filter the data. For more information refer to pandas.DataFrame.query.
Note
Only applicable for the vector
layer_type
.- postgres: bool, default False
Whether to use a PostgreSQL database connection to read the layer. The connection has to already exist and be stored in the
conn
attribute using theset_postgres()
method.- base_layer: bool, default False
Whether the layer should be used as a
base_layer
for the data processing.- resample: str, default ‘nearest’
Sets the default method to use when resampling the dataset. Resampling occurs when changing the grid cell size of the raster, thus the values of the cells need to be readjusted to reflect the new cell size. Several sampling methods can be used, and which one to use is dependent on the nature of the data. For a list of the accepted methods refer to rasterio.enums.Resampling.
See also
- normalization: str, ‘MinMax’
Sets the default normalization method to use when calling the
RasterLayer.normalize()
. Currently, the only available option is ‘MinMax’. This is relevant to calculate thedemand_index
,supply_index
,clean_cooking_index
andassistance_need_index
of theMCA
model.Note
If the
layer_type
is vector, this parameters will be passed to any raster dataset created from the vector layer, for example seeVectorLayer.distance_raster
.- inverse: bool, default False
Sets the default mode for the normalization algorithm (see
RasterLayer.normalize()
). If False, then the raster will be normalized (ifnormalize_rasters()
is called) setting 1 as the high value and 0 as the low. If True, then the raster will be normalized setting the high value as 0 and the low values as 1.Note
If the
layer_type
is vector, this parameters will be passed to any raster dataset created from the vector layer, for example seeVectorLayer.distance_raster
.- distance_method: str, optional
Sets the default distance algorithm to use when calling the
get_distance_raster()
method for the layer, seeVectorLayer
andRasterLayer
.- distance_limit: Callable object (function or lambda function) with a numpy array as input, optional
Defines a distance limit or range to consider when calculating the distance raster, see
VectorLayer
andRasterLayer
.- window: rasterio.windows.Window or gpd.GeoDataFrame
A window or bounding box to read in the data if
layer_type
is raster or vector respectively. See thewindow
parameter ofRasterLayer
and thebbox
parameter ofVectorLayer
.- rescale: bool, default False
Sets the default value for the
rescale
attribute. This attribute is used in thealign()
method to rescale the values of a cell proportionally to the change in size of the cell. This is useful when aligning rasters that have different cell sizes and their values can be scaled proportionally. See therescale
parameter ofRasterLayer
.
See also
set_postgres
get_distance_raster
VectorLayer
RasterLayer