rasterize

eolab.georastertools.processing.vector.rasterize(geoms: GeoDataFrame | Path | str, raster: Path | str, burn: str = 'index', burn_type='int32', nodata=-1, output: Path | str | None = None)[source]

Rasterize geometries using the raster shape and CRS. Output is a GeoTiff where every pixels have the value of the “burn” attribute of geometries.

Parameters:
  • geoms (str or Path or gpd.GeoDataFrame) – Filename of the vector data (if str) or GeoDataFrame

  • raster (str or Path) – Filename of the raster image

  • burn (str, optional, default='index') – Attribute to burn in the raster. Default is the index of the geometry.

  • burn_type (rasterio.dtypes, optional, default=rasterio.int32) – Type of the attribute values to burn. Must be coherent with actual burned attribute.

  • nodata (value compatible with burn_type, optional, default=-1) – Value corresponding to nodata in the generated raster.

  • output (str or Path, optional, default=None) – Output file where to save the rasterized geometries. If None, nothing written to disk (only in memory)

Returns:

The dataset containing the burned values

Return type:

np.ndarray