get_valid_vector

Contents

get_valid_vector#

get_valid_vector(ds: str | tuple | DatasetReader, default_nodata: int = 0) GeoDataFrame[source]#

Get the valid data 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 get_footprint.

Parameters:
  • ds (PATH_ARR_DS) – Path to the raster, its dataset, its xarray or a tuple containing its array and metadata

  • 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"  # 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