geodata.Mask.add_shape_layer#
- geodata.Mask.add_shape_layer(shapes: dict[str, shapely.Geometry], reference_layer: str | None = None, resolution: tuple[float, float] | None = None, combine_name: str | None = None, exclude: bool = False, buffer: float = 0.0, src_crs: str = 'EPSG:4326', buffer_crs: str = 'EPSG:6933', dst_crs: str = 'EPSG:4326', **kwargs)#
Add shapes to the mask layers. This is different from shape extractions, as we will simply treat one shp file as a layer, instead of grabbing the merged mask within that shape. This method take in a dictionary of shapes, a resolution of the result raster with that shape, and add the shape to the mask object. Users can also use a reference layer that is present in the mask object to avoid manuelly finding resolution.
- Parameters:
shapes (dict) – A dictionary of key, shape pair. Shapes should be a supported geometry type in shapely.
reference_layer (str) – Name to the layer which bounds/resolution is used. If not specified, the method will use the layer with the best (highest) resolution.
resolution (tuple[float, float]) – A tuple of (width_resolution, height_resoution). If specified with a reference layer, the method ignore the resolution of the referenced layer and use the input resolution instead.
combine_name (str) – The name of the combined shape. If specified here, Mask will combine all input shapes into one layer.
exclude (bool) – Whether we want to exclude the area specified by the shape or the area not specified by shape. By default, this is set to False.
buffer (float) – Round buffer distance in km^2 extending out the shapes. If input is greater than 0, this method will give approximate representation of all points within this given distance of the shapes objects.
src_crs (str) – The source raster’s CRS, by default it is ‘EPSG:4326’ lat lon coordinate system.
buffer_crs (str) – The CRS for the buffer. By default it is ‘EPSG:6933’ meter coordinate system.
dst_crs (str) – The destination CRS, by default it is ‘EPSG:4326’ lat lon coordinate system.
**kwargs – Additional arguments passed to the rasterio.features.geometry_mask method.