geoutils.Vector.rasterize#
- Vector.rasterize(ref=None, in_value=None, out_value=0, all_touched=False, out_dtype=None, res=None, shape=None, grid_coords=None, bounds=None, crs=None, *, chunksizes=None, mp_config=None, dask=False, **kwargs)[source]#
Rasterize vector to a raster or mask, with input geometries burned in.
Match-reference: a raster can be passed to match its resolution, bounds and CRS when rasterizing the vector.
Alternatively, user can specify a grid to rasterize on using xres, yres, bounds and crs. Only xres is mandatory, by default yres=xres and bounds/crs are set to self’s.
Burn value is set by user and can be either a single number, or an iterable of same length as self.ds. Default is an index from 1 to len(self.ds).
- Parameters:
ref (
TypeVar(RasterType, bound= RasterBase) |None) – Reference raster to match during rasterization.crs (
CRS|int|None) – Coordinate reference system as string or EPSG code (Default to raster.crs if not None then self.crs).res (
tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |int|float|integer[Any] |floating[Any] |None) – Output raster spatial resolution.bounds (
tuple[float,float,float,float] |None) – Output raster bounds (left, bottom, right, top). Only if raster is None. Must be in same system as crs, if set. (Default to self bounds).in_value (
int|float|Iterable[int|float] |None) – Value(s) to be burned inside the polygons (Default is self.ds.index + 1).out_value (
int|float) – Value to be burned outside the polygons (Default is 0).
- Return type:
TypeVar(RasterType, bound= RasterBase)- Returns:
Raster or mask containing the burned geometries.