imod.prepare.rasterize#
- imod.prepare.rasterize(geodataframe: gpd.GeoDataFrame, like: DataArray, column: str | int | float | None = None, fill: float | int | None = nan, dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] = None, **kwargs) DataArray [source]#
Rasterize a geopandas GeoDataFrame onto the given xarray coordinates.
- Parameters:
geodataframe (geopandas.GeoDataFrame) – Geodataframe with polygons to rasterize.
like (xarray.DataArray) – Example DataArray. The rasterized result will match the shape and coordinates of this DataArray.
column (str, int, float, optional) – column name of geodataframe to burn into raster
fill (float, int, optional) – Fill value for nodata areas. Optional, default value is np.nan.
dtype (dtypelike, optional) – Data type of output raster. Defaults to data type of grid provided as “like”.
kwargs (additional keyword arguments for rasterio.features.rasterize, optional) – See: https://rasterio.readthedocs.io/en/stable/api/rasterio.features.html#rasterio.features.rasterize
- Returns:
rasterized – Vector data rasterized. Matches shape and coordinates of
like
.- Return type:
xarray.DataArray