1

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?

1
  • 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

1 Answer 1

0

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.