geoutils.Vector.create_mask#
- Vector.create_mask(ref=None, all_touched=False, crs=None, res=None, bounds=None, shape=None, grid_coords=None, points=None, *, as_array=False, chunksizes=None, mp_config=None, dask=False)[source]#
- Overloads:
self, ref (RasterLike | PointCloudLike | None), all_touched (bool), crs (CRS | None), res (float | tuple[float, float] | None), bounds (tuple[float, float, float, float] | None), shape (tuple[int, int] | None), grid_coords (tuple[NDArrayNum, NDArrayNum] | None), points (tuple[NDArrayNum, NDArrayNum] | None), as_array (Literal[False]), chunksizes (tuple[int, int] | None), mp_config (MultiprocConfig | None), dask (bool) → Raster | PointCloud
self, ref (RasterLike | PointCloudLike | None), all_touched (bool), crs (CRS | None), res (float | tuple[float, float] | None), bounds (tuple[float, float, float, float] | None), shape (tuple[int, int] | None), grid_coords (tuple[NDArrayNum, NDArrayNum] | None), points (tuple[NDArrayNum, NDArrayNum] | None), as_array (Literal[True]), chunksizes (tuple[int, int] | None), mp_config (MultiprocConfig | None), dask (bool) → NDArrayBool
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 (RasterLike | PointCloudLike | None) – Reference raster or pointcloud to use during masking.
res (float | tuple[float, float] | None) – (Only for raster masking) Spatial resolution of mask. Required if no reference is passed.
points (tuple[NDArrayNum, NDArrayNum] | None) – (Only for point cloud masking) Point X/Y coordinates of mask. Required if no reference is passed.
bounds (tuple[float, float, float, float] | None) – (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 (CRS | None) – Coordinate reference system for output mask. Optional, defaults to this vector’s crs. Only used if no reference is passed.
as_array (bool) – Whether to return mask as a boolean array.
- Returns:
A raster or point cloud mask.