get_nodata_vector#
- get_nodata_vector(ds: str | CloudPath | Path | tuple[ndarray | MaskedArray, dict] | DataArray | Dataset | DatasetReader | DatasetWriter, default_nodata: int = 0) GeoDataFrame [source]#
Get the nodata vector of a raster as a vector.
Pay attention that every nodata pixel will appear too. If you want only the footprint of the raster, please use
rasters.get_footprint
.- Parameters:
ds (PATH_ARR_DS) – Path to the raster, its dataset, its
xarray
or a tuple containing its array and metadatadefault_nodata (int) – Default values for nodata in case of non-existing in file
- Returns:
Nodata Vector
- Return type:
gpd.GeoDataFrame
Examples
>>> raster_path = "path/to/raster.tif" # Classified raster, with no data set to 255 >>> nodata1 = get_nodata_vec(raster_path) >>> >>> # or >>> with rasterio.open(raster_path) as ds: >>> nodata2 = get_nodata_vec(ds) >>> >>> # Assert those two approaches give the same result >>> nodata1 == nodata2 True