Bug report #14106

gdal info -stats are approximate if ".aux.xml" has been created.

Added by Nicolas Cadieux almost 5 years ago. Updated over 1 year ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Rasters
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:22112

Description

When Using gdalinfo with the "-stats" switch, raster statistics are exact only if the ".aux.xml" file has not been created. If the .aux.xml file has been created by qgis, statistics are approximate. This is a big problem as the only way to get the correct statistic is to close QGIS, delete the file and Start Qgis again. The processing "Raster Layer Statistics" works all the time.

gdal_info.txt Magnifier (8.79 KB) Nicolas Cadieux, 2016-01-19 07:15 AM

REAL_dtm_1km_6185_693.tif.aux.xml Magnifier (334 Bytes) Giovanni Manghi, 2016-05-23 10:26 AM

APROX_dtm_1km_6185_693.tif.aux.xml Magnifier (340 Bytes) Giovanni Manghi, 2016-05-23 10:26 AM

History

#1 Updated by Alexander Bruy almost 5 years ago

  • Status changed from Open to Feedback

Works fine here.

Do you have this bug also when running gdalinfo from console?

#2 Updated by Nicolas Cadieux almost 5 years ago

I have had this issues since at least QGIS 2.4 on multiplie Windows 7_64 machines all using the OSGeo4W64.

Steps to reproduce:
a: Start QGIS and go to a Directory will 1 tiff file only.
b: Go to raster/miscellaneous/information and add -stats: "gdalinfo H:/Dem_sol_151013.tiff -stats". Press enter. This will take a while(raster is 84GB): Minimum=-0.920, Maximum=787.450, Mean=335.777, StdDev=179.543
c:Close qgis while not saving the project: Dem_sol_151013.tiff.aux.xml is now in the directory
d:Open QGIS and try steps b: This will be fast: Minimum=-0.630, Maximum=778.970, Mean=335.169, StdDev=179.670

Results are identical when using gdalinfo -stats at the OSGeo4W shell.

Once the xml file is wrote, there is now way of getting the correct exact stats. As stat contained in the file override the exacts statistics:
xml: <Metadata>
<MDI key="STATISTICS_MAXIMUM">778.96997070313</MDI>
<MDI key="STATISTICS_MEAN">335.16934270393</MDI>
<MDI key="STATISTICS_MINIMUM">-0.62999999523163</MDI>
<MDI key="STATISTICS_STDDEV">179.66989242974</MDI>
</Metadata>
See file.

If this is the default (and it should not be), it should be noted very clearly as this can really have an impact on research. Steps to have the correct specific stats should be available in GUI.
Hope this helps.

#3 Updated by Alexander Bruy almost 5 years ago

Sorry I still can not reproduce it here. I always get same result with or without .aux.xml file.

If you get wrong results when running gdalinfo directly from command line, than this looks like GDAL bug.

#4 Updated by Giovanni Manghi over 4 years ago

Alexander Bruy wrote:

Sorry I still can not reproduce it here. I always get same result with or without .aux.xml file.

If you get wrong results when running gdalinfo directly from command line, than this looks like GDAL bug.

Hi Alexander,
I see the difference/issue, and you can see the related ticket comment here (and sample data)

#14835-8

by default QGIS computes stats in an approximate way, once the .aux.xml with approximate stats then gdalinfo will use it. The .aux.xml is update with real stats only if the user chooses "accuracy: actual/slower" in raster properties.

#5 Updated by Giovanni Manghi over 3 years ago

  • Regression? set to No
  • Easy fix? set to No

#6 Updated by Giovanni Manghi over 1 year ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF