Bug report #6496
Wrong min/max values for rasters
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||all||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||15717|
When I load min/max values for raster layer (need them to set symbology) QGIS loads wrong values. For example, for attached raster QGIS reports min=1363.82 and max=2998.83 when using options "Full extent", "Actual (slower)" and "Min / max". In same time gdalinfo gives another (correct) values MINIMUM=1358.3345947266 and MAXIMUM=3031.4431152344.
Seems even using "Actual (slower)" option QGIS still returns approximate statistics instead of exact. Possible workaround is to delete .aux files created by QGIS and recompute statistics using gdalinfo. But this is not very userfriendly IMO
#1 Updated by Radim Blazek about 8 years ago
It seems that GDALGetRasterStatistics() is giving cached estimated statistics if called with bApproxOK=false and bForce=false if exact statistics (from all raster pixels) are not available.
I have sent a question to GDAL list:
#2 Updated by Radim Blazek about 8 years ago
- Resolution set to fixed
- Status changed from Open to Closed
Fixed in 9ad9f8c.
Unfortunately GDAL does not seem to be able to recognize if its cached stats are estimated or exact, so we have to force recalculation if exact stats are requested in QGIS even if exact stats are cached by GDAL (we cannot be sure that are exact).