onstove.OnStove.add_layer#

OnStove.add_layer(category: str, name: str, path: str, layer_type: str, query: str = None, postgres: bool = False, base_layer: bool = False, resample: str = 'nearest', normalization: str = 'MinMax', inverse: bool = False, distance_method: str = 'proximity', distance_limit: Callable[[ndarray], ndarray] | None = None, window: Window | None = None, rescale: bool = False)#

Adds a new layer (type VectorLayer or RasterLayer) to the MCA 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”. This 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 from. The connection needs be already created and stored in the conn attribute using the set_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

RasterLayer

normalization: str, ‘MinMax’

Sets the default normalization method to use when calling the RasterLayer.normalize(). This is relevant to calculate the demand_index, supply_index, clean_cooking_index and assistance_need_index of the MCA model.

Note

If the layer_type is vector, this parameters will be passed to any raster dataset created from the vector layer, for example see VectorLayer.distance_raster.

inverse: bool, default False

Sets the default mode for the normalization algorithm (see RasterLayer.normalize()).

Note

If the layer_type is vector, this parameters will be passed to any raster dataset created from the vector layer, for example see VectorLayer.distance_raster.

distance_method: str, default ‘proximity’

Sets the default distance algorithm to use when calling the get_distance_raster() method for the layer, see VectorLayer and RasterLayer.

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 and RasterLayer.

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 the window parameter of RasterLayer and the bbox parameter of VectorLayer.

rescale: bool, default False

Sets the default value for the rescale attribute. See the rescale parameter of RasterLayer.