Is there a similar way as in ArcPy
import arcpy
desc=arcpy.Describe('rasterName')
print desc.noDataValue
to access the no data value using GDAL?
Is there a similar way as in ArcPy
import arcpy
desc=arcpy.Describe('rasterName')
print desc.noDataValue
to access the no data value using GDAL?
The answer is given in Python:Alternatives to using Arcpy
from osgeo import gdal
srs = gdal.Open("dem_maido_tipe.tif")
srs.RasterCount
1
print(srs.GetRasterBand(1).GetNoDataValue())
-32768.0
srs = gdal.Open("geol_map.tif")
srs.RasterCount
3
print(srs.GetRasterBand(1).GetNoDataValue())
None
for i in range(srs.RasterCount):
print(srs.GetRasterBand(i+1).GetNoDataValue())
None
None
None
And you can also use rasterio, more user-friendly library of GDAL data model
import rasterio
src = rasterio.open("dem_maido_tipe.tif")
print(src.nodatavals)
(-32768.0,)
src = rasterio.open("geol_map.tif")
print(src.nodatavals)
(None, None, None)