I want to get extent of raster dataset after excluding the extents containing no-data values in the raster data which I then want to export as a shapefile. Till now I have used the following code:
import rasterio
with rasterio.open(r'C:\Users\Desktop\PRODUCT1\Landsat\T1.tif') as src:
bounds = src.bounds
from shapely.geometry import box
geom = box(*bounds)
import geopandas as gpd
df = gpd.GeoDataFrame({"id":1,"geometry":[geom]})
df.crs = src.crs
df.to_file(r"C:\Users\Desktop\PRODUCT1\Landsat\T1_boundary.shp")
After running the above code I am getting raster extents containing no-data values.
Can someone please help me out in getting the raster extents excluding the extents having no-data values.