Bug report #6496

Wrong min/max values for rasters

Added by Alexander Bruy almost 12 years ago. Updated almost 12 years ago.

Status:Closed
Priority:Normal
Assignee:Radim Blazek
Category: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

Description

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

logan.tar.bz2 - Sample raster (4.86 MB) Alexander Bruy, 2012-10-11 04:35 AM

History

#1 Updated by Radim Blazek almost 12 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:
http://lists.osgeo.org/pipermail/gdal-dev/2012-October/034318.html

#2 Updated by Radim Blazek almost 12 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).

Also available in: Atom PDF