geoutils.Vector.create_mask#
- Vector.create_mask(ref=None, crs=None, res=None, bounds=None, points=None, as_array=False)[source]#
Create a raster or point cloud mask from the vector features (True if pixel/point contained by any vector feature, False if not).
For a raster reference, creates a raster mask with the resolution, bounds and CRS of the reference raster. For a point cloud reference, creates a point mask with the coordinates and CRS of the reference point cloud.
Alternatively, for a raster mask, one can specify a grid to rasterize on based on bounds, resolution and CRS. For a point mask, one can specify the points coordinates and CRS.
- Parameters:
ref – Reference raster or pointcloud to use during masking.
res – (Only for raster masking) Spatial resolution of mask. Required if no reference is passed.
points – (Only for point cloud masking) Point X/Y coordinates of mask. Required if no reference is passed.
bounds – (Only for raster masking) Bounds of mask (left, bottom, right, top). Optional, defaults to this vector’s bounds. Only used if no reference is passed.
crs – Coordinate reference system for output mask. Optional, defaults to this vector’s crs. Only used if no reference is passed.
as_array – Whether to return mask as a boolean array.
- Returns:
A raster or point cloud mask.