I am confused about why if I open a band with GDAL I get, for example, band.GetMaximun(): 1000
, but if I do ReadAsArray
I get myArray.max(): 1200
(the same if I do np.max(myArray)
). Does someone knows why this difference?
-
Could you share more code that highlights how you are loading your data and accessing your functions?– Aaron ♦Commented Jul 1, 2015 at 11:30
Add a comment
|
1 Answer
The difference is most likely due to outdated statistics in your GeoTiff. band.GetMaximum()
will read the value from the precomputed statistics, which are included in the GeoTiff.
If you want to update the statistics you can either use gdalinfo -stats
or do it with the Python bindings, provided you have write access to the file.
from osgeo import gdal
ds = gdal.Open("myGeo.tif", gdal.GA_Update)
ds.GetRasterBand(1).ComputeStatistics()