[gdal-dev] Hi: Bug report gdal_translate

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Tue Nov 2 02:16:01 PDT 2021


Hi,

I believe that you have found a bug in the Surfer documentation. You can see value 1.70141e+38, that is the maximum single precision float, used in for example
https://support.goldensoftware.com/hc/en-us/articles/226806408-How-do-I-make-all-Z-values-above-or-below-a-certain-threshold-value-transparent-in-Surfer-?mobile_site=false 

The GDAL AAIGRID driver does not seem to have a default value for nodata https://gdal.org/drivers/raster/aaigrid.html. The driver copies the nodata from the source dataset if it exists https://github.com/OSGeo/gdal/blob/master/frmts/aaigrid/aaigriddataset.cpp#L1275. There is some nodata handling in the code:
// Cast to float and back for make sure the NoData value matches
// that expressed by a float value.  Clamps to the range of a float
// if the value is too large.  Preserves +/-inf and NaN.

Maybe there should be a default nodata value, -9999 https://www.loc.gov/preservation/digital/formats/fdd/fdd000421.shtml
"Cells without actual values can be assigned a NoData value. The default value for NoData is -9999 but a different value can be specified in the header as shown in example below."

I read the comment "NoData values appear as 1.71041e38" from http://surferhelp.goldensoftware.com/topics/ascii_grid_file_format.htm so that it is the value how nodata appears in Surfer. You can test it by creating some ASCII grid files with different nodata values and opening them with Surfer. Commands would look like this "gdal_translate -of AAIGRID -a_nodata -99".

There may be a bug in theAAIGRID driver if the nodata in your source data and the nodata transferrer into ASCII grid files are different. Check the nodata values with gdalinfo. If nodata remains the same there is no bug. If you have 1.71041E+38 as nodata in your source data, what it the format and bit depth of the data?

-Jukka Rahkonen-
 
-----Alkuperäinen viesti-----
Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Dr. Felix Tritschler
Lähetetty: tiistai 2. marraskuuta 2021 8.32
Vastaanottaja: gdal-dev at lists.osgeo.org
Aihe: [gdal-dev] Bug report gdal_translate

Hello,

I stumbled across what appears to me as an typo in the gdal_translate function implemented in QGIS 3.18.2.
I performed a translation from a geotiff to a surfer (non-binary) .grd file without a specification of a NODATA-Value.

In the resulting .grd-file the NODATA value was 1.70141E+38.
But according to
http://surferhelp.goldensoftware.com/topics/ascii_grid_file_format.htm
the correct NODATA value for this filetype has to be 1.71041E+38.

I don't feel skilled enough to fix this bug on my own (even don't know if I could do this =o), so please feel free to check and fix if necessary.

Cheers
Felix

_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list