get_valid_vector#
- get_valid_vector(xds: str | CloudPath | Path | tuple[ndarray | MaskedArray, dict] | DataArray | Dataset | DatasetReader | DatasetWriter, default_nodata: int = 0) GeoDataFrame [source]#
Get the valid data of a raster, returned 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:
xds (AnyRasterType) – Path to the raster or a rasterio dataset or a xarray
default_nodata (int) – Default values for nodata in case of non-existing in file
- Returns:
Nodata Vector
- Return type:
gpd.GeoDataFrame
Example
>>> raster_path = "path/to/raster.tif" >>> 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