[gdal-dev] gdal_translate truncates nodata_value < -4.21358e-09

Even Rouault even.rouault at spatialys.com
Fri Apr 10 13:49:06 PDT 2015


Siebe,

I've created the following test file:

$ cat test.asc
ncols        2
nrows        2
xllcorner    0
yllcorner    0
cellsize     1
NODATA_value  -3.40282346638529E+38
 -3.40282346638529E+38 0
1 2


$ gdalinfo test.asc -stats
Driver: AAIGrid/Arc/Info ASCII Grid
Files: test.asc
Size is 2, 2
Coordinate System is `'
Origin = (0.000000000000000,2.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Corner Coordinates:
Upper Left  (   0.0000000,   2.0000000) 
Lower Left  (   0.0000000,   0.0000000) 
Upper Right (   2.0000000,   2.0000000) 
Lower Right (   2.0000000,   0.0000000) 
Center      (   1.0000000,   1.0000000) 
Band 1 Block=2x1 Type=Float32, ColorInterp=Undefined
  Minimum=0.000, Maximum=2.000, Mean=1.000, StdDev=0.816
  NoData Value=-3.4028234663852886e+38
  Metadata:
    STATISTICS_MAXIMUM=2
    STATISTICS_MEAN=1
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=0.81649658092773

==> So the nodata value is well taken into account, and the pixel at position 
(0,0) that is at nodata is well excluded from the stats.


Then converting it again to AAIGRID :

$ gdal_translate test.asc test2.asc -of aaigrid

$ cat test2.asc
ncols        2
nrows        2
xllcorner    0.000000000000
yllcorner    0.000000000000
cellsize     1.000000000000
NODATA_value  -3.4028234663852885981e+38
 -3.4028234663852885981e+38 0
 1 2

(slightly different last figures, but as we output 20 and than only 15 or 16 are 
really significant, that doesn't matter)

Confirmed by computing again statistics :

$ gdalinfo -stats test2.asc
Driver: AAIGrid/Arc/Info ASCII Grid
Files: test2.asc
Size is 2, 2
Coordinate System is `'
Origin = (0.000000000000000,2.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Corner Coordinates:
Upper Left  (   0.0000000,   2.0000000) 
Lower Left  (   0.0000000,   0.0000000) 
Upper Right (   2.0000000,   2.0000000) 
Lower Right (   2.0000000,   0.0000000) 
Center      (   1.0000000,   1.0000000) 
Band 1 Block=2x1 Type=Float32, ColorInterp=Undefined
  Min=0.000 Max=2.000 
  Minimum=0.000, Maximum=2.000, Mean=1.000, StdDev=0.816
  NoData Value=-3.4028234663852886e+38
  Metadata:
    STATISTICS_MAXIMUM=2
    STATISTICS_MEAN=1
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=0.81649658092773

Then converting to HFA :

$ gdal_translate test2.asc test2.img -of hfa

And again checking statistics :

$ gdalinfo test2.img -stats
Driver: HFA/Erdas Imagine Images (.img)
Files: test2.img
Size is 2, 2
Coordinate System is `'
Origin = (0.000000000000000,2.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Corner Coordinates:
Upper Left  (   0.0000000,   2.0000000) 
Lower Left  (   0.0000000,   0.0000000) 
Upper Right (   2.0000000,   2.0000000) 
Lower Right (   2.0000000,   0.0000000) 
Center      (   1.0000000,   1.0000000) 
Band 1 Block=64x64 Type=Float32, ColorInterp=Undefined
  Description = Layer_1
  Minimum=0.000, Maximum=2.000, Mean=1.000, StdDev=0.816
  NoData Value=-3.4028234663852886e+38
  Metadata:
    LAYER_TYPE=athematic
    STATISTICS_MAXIMUM=2
    STATISTICS_MEAN=1
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=0.81649658092773

So I'm not sure how to reproduce your problem.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list