short integer overflow with AAGRID when input grid contains some 32bit integers
|Reported by:||dylan||Owned by:||Even Rouault|
There appears to be a problem with GDAL utilities not recognizing the possibility that an AAGRID file may contain a mixture of 16 and 32 bit integers. This is not surprising, as the AAGRID file format does not contain any hints about its contents. A ticket was started on the GRASS tracker, but the issue appears to be a purely GDAL bug.
One idea for a fix includes an environmental flag which would cause the AAGRID driver to scan the input file in order to properly determine an appropriate data type. Another approach would be to manually set the data type for any input file from the command line.
Example using the attached file:
gdal_translate big_int_arc_file.asc test.tiff
the resulting file is produced:
gdalinfo -stats test.tiff Driver: GTiff/GeoTIFF Files: test.tiff Size is 7, 7 Coordinate System is `' Origin = (592000.000000000000000,4926000.000000000000000) Pixel Size = (1000.000000000000000,-1000.000000000000000) Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( 592000.000, 4926000.000) Lower Left ( 592000.000, 4919000.000) Upper Right ( 599000.000, 4926000.000) Lower Right ( 599000.000, 4919000.000) Center ( 595500.000, 4922500.000) Band 1 Block=7x7 Type=Int16, ColorInterp=Gray Minimum=-31293.000, Maximum=32420.000, Mean=216.837, StdDev=18087.589 NoData Value=-9999 Metadata: STATISTICS_MINIMUM=-31293 STATISTICS_MAXIMUM=32420 STATISTICS_MEAN=216.83673469388 STATISTICS_STDDEV=18087.589140406