geoutils.Vector.create_mask#
- Vector.create_mask(raster=None, crs=None, xres=None, yres=None, bounds=None, buffer=0, as_array=False)[source]#
Create a mask from the vector features.
Match-reference: a raster can be passed to match its resolution, bounds and CRS when creating the mask.
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.
Vector features which fall outside the bounds of the raster file are not written to the new mask file.
- Parameters:
raster (
Raster
|None
) – Reference raster to match during rasterization.crs (
CRS
|None
) – A pyproj or rasterio CRS object (Default to raster.crs if not None then self.crs)xres (
float
|None
) – Output raster spatial resolution in x. Only is raster is None.yres (
float
|None
) – Output raster spatial resolution in y. Only if raster is None. (Default to xres)bounds (
tuple
[float
,float
,float
,float
] |None
) – Output raster bounds (left, bottom, right, top). Only if raster is None (Default to self bounds)buffer (
int
|float
|integer
[Any
] |floating
[Any
]) – Size of buffer to be added around the features, in the raster’s projection units. If a negative value is set, will erode the features.as_array (
bool
) – Return mask as a boolean array
- Return type:
- Returns:
A Mask object contain a boolean array