#3573 closed defect (fixed)
gdalinfo -stats and numeric imprecision on dataset with nodata
Reported by: | maphew | Owned by: | Even Rouault |
---|---|---|---|
Priority: | normal | Milestone: | 1.7.3 |
Component: | Utilities | Version: | |
Severity: | normal | Keywords: | gdalinfo |
Cc: | Kyle Shannon, jjr8 |
Description
When I run gdalinfo -stats on a 32bit 1-band tiff (elevation model) it renders the image unviewable in Arcmap 9.3.1sp1. Arccatalog & Arcmap report all the usual info as for as datatype presence of pyramids and so on, it just draws as white. There is no error message.
Before calculating statistics Arcmap reports high/low values in the form of:
High : 3.40282e+038 Low : 1.17549e-038
and after gdalinfo -stats it becomes:
High : 1952.5 Low : -3.40282e+038
After playing with Arcmap symbology and using contrast stretch, std devations, etc. The Low changes to:
Low : -340282346638529990000000000000000000000.000000
Arccatalog reports NoData: -3.4028235e+038
The raster can be made to display by instructing Arcmap to use "Stretched>Min/Max>Edit-High-Low" and change the bottom end to the real minimum value, or at least 0. This is not a real solution as it's only good for that particular Arcmap session. Deleting the "foobar.tif.aux.xml"works better.
Using ArcGIS to calulate statistics on the same file after deleting .aux.xml reveals the true min/max statistics:
High : 580.340637 Low : 213.000000
I'm using GDAL 1.7.0dev, released 2008/11/26 on Windows7 x64 via OSGeo4w.
Attachments (1)
Change History (6)
by , 13 years ago
Attachment: | stats-no-draw.7z added |
---|
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
Owner: | changed from | to
---|---|
Summary: | gdalinfo -stats incompatible with ArcMap 9.3.1 → gdalinfo -stats and numeric imprecision on dataset with nodata |
comment:3 by , 13 years ago
Cc: | added |
---|
comment:4 by , 13 years ago
Milestone: | → 1.7.3 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | 1.7.0 |
The reason is that the nodata value wasn't ignored when computing the stats. Nodata value is stored in GeoTIFF files as a text value, but the pixel values are stored as IEEE floats. So strict comparison can fail. The fix is to test that the relative difference between nodata and pixel values is small (1e-10), but not exactly 0.
Fixed in trunk (r19669) and branches/1.7 (r19671). Test added in r19670
After fix, gdalinfo -stats small/orig/dem.tif returns :
Band 1 Block=493x4 Type=Float32, ColorInterp=Gray Minimum=213.000, Maximum=578.979, Mean=355.119, StdDev=84.672 NoData Value=-3.40282346638528898e+38 Metadata: LAYER_TYPE=athematic STATISTICS_MINIMUM=213 STATISTICS_MAXIMUM=578.97894287109 STATISTICS_MEAN=355.11909149198 STATISTICS_STDDEV=84.671745438196
data set with original elevation model, after gdal stats and after arcgis stats