rasterize#
- rasterize(ds: str | ~cloudpathlib.cloudpath.CloudPath | ~pathlib.Path | ~typing.Tuple[~numpy.ndarray | ~numpy.ma.MaskedArray, dict] | ~xarray.core.dataarray.DataArray | ~xarray.core.dataset.Dataset | ~rasterio.io.DatasetReader | ~rasterio.io.DatasetWriter, vector: ~geopandas.geodataframe.GeoDataFrame | str | ~cloudpathlib.cloudpath.CloudPath | ~pathlib.Path, value_field: str = None, default_nodata: int = 0, default_value: int = 1, **kwargs) -> (<class 'numpy.ma.MaskedArray'>, <class 'dict'>)[source]#
Rasterize a vector into raster format.
Note that passing merge_alg = MergeAlg.add will add the vector values to the given a raster
See: https://pygis.io/docs/e_raster_rasterize.html
- Parameters:
ds (AnyRasterType) – Path to the raster, its dataset, its
xarray
or a tuple containing its array and metadatavector (Union[gpd.GeoDataFrame, AnyPathStrType]) – Vector to be rasterized
value_field (str) – Field of the vector with the values to be burnt on the raster (should be scalars). If let to None, the raster will be binary (default_nodata, default_value).
default_nodata (int) – Default nodata of the raster (outside the vector in the raster extent)
default_value (int) – Used as value for all geometries, if value_field not provided
- Returns:
Rasterized vector and its metadata
- Return type:
np.ma.masked_array, dict