qgis – Solving QGIS-3 Not Recognizing ‘-3.40282e+38’ Float Raster Values as NoData

gdalnodataqgisqgis-3raster

I have DEMs with "-3.40282e+38" values that are supposed to be the NoData values. However, if the rasters are loaded into QGIS (3.4.11), the value can not get assigned with "add additional no data value" via the transparency tab.

When this value is assigned with gdal_translate -a_nodata -3.40282e+38 input.tif output.tif the output.tif shows this value as NoData but QGIS still does not recognize it.
However, if the NoData value is computed in the tif properties in ArcCatalog and then exportet as a new tif, the assigned NoData value of the exported tif is recognized in QGIS.

How can I assign such large float values as NoData in QGIS (or GDAL)?

I am using QGIS 3.4.11 LTR on a Linux Mint 19.2 operating system.
Edit: GDAL version 2.2.3 is used

Best Answer

According to this site, the value of -3.40282e38 is 0xff7fffee, which is a 'quiet' NaN ("Not a number") value according to this page .

NaN is a sensible way to represent NODATA. Certain ranges of binary values for floats are used to represent NaN, infinity, minus infinity and so on.

This nodata value suggests the original is single precision floating point (e.g. float32)

It could be that

  • your current GDAL or QGIS doesn't recognise this bit pattern as a NaN
  • saving it in ArcGIS converts it to a NaN that QGIS does understand
  • it might be that GDAL is defaulting to 64 bit output?

It might help if you can edit your question to include the GDAL version (you should be able to get this from QGIS, using QGIS > About QGIS

I would maybe try setting the output type in gdal_translate to float32, e.g. using the -ot Float32 option to see if that works.