hydromt.DataArray.raster.rasterize#

DataArray.raster.rasterize(gdf, col_name='index', nodata=0, all_touched=False, dtype=None, sindex=False, **kwargs)#

Return an object with input geometry values burned in.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame of shapes and values to burn.

  • col_name (str, optional) – GeoDataFrame column name to use for burning, by default ‘index’.

  • nodata (int or float, optional) – Used as fill value for all areas not covered by input geometries. 0 by default.

  • all_touched (bool, optional) – If True, all pixels touched by geometries will be burned in. If false, only pixels whose center is within the polygon or that are selected by Bresenham’s line algorithm will be burned in.

  • dtype (numpy dtype, optional) – Used as data type for results, by default it is derived from values.

  • sindex (bool, optional) – Create a spatial index to select overlapping geometries before rasterizing, by default False.

  • kwargs (optional) – Additional keyword arguments to pass to features.rasterize.

Returns:

DataArray with burned geometries

Return type:

xarray.DataArray

Raises:

ValueError – If no geometries are found inside the bounding box.