get_extent#
- get_extent(xds: str | DataArray | Dataset | DatasetReader) GeoDataFrame [source]#
Get the extent of a raster as a
geopandas.Geodataframe
.- Parameters:
xds (PATH_XARR_DS) – Path to the raster or a rasterio dataset or a xarray
- Returns:
Extent as a
geopandas.Geodataframe
- Return type:
gpd.GeoDataFrame
Example
>>> raster_path = "path/to/raster.tif" >>> >>> extent1 = get_extent(raster_path) >>> >>> # or >>> with rasterio.open(raster_path) as ds: >>> extent2 = get_extent(ds) >>> >>> # Assert those two approaches give the same result >>> extent1 == extent2 True