[gdal-dev] using NaN as no-data value
Even Rouault
even.rouault at spatialys.com
Mon Mar 30 07:18:28 PDT 2026
Javier,
> I have seen some GeoTIFFs for DSMs (float32) with NaN as no-data
> value. It was not set in the metadata, but worked as that.
Most (I wouldn't claim "all") code in GDAL that does no-data checking
does for floating point values "if (std::isnan(pixel_val) || pixel_val
== nodata)", so yes, even when not advertized as the band nodata value,
a NaN pixel will be deal as it
> I think I have also seen it with NaN set in the metadata.
> Also many other numbers as no-data value, like -10000 or -9999 or
> -8888 (yes, and many other posible values).
>
> Is there any reason to prefer or discourage NaN as a no-data value for
> a float32 GeoTIFF?
If you are curious there is a 10 page essay on that topic on
https://docs.ogc.org/per/24-040r1.html#Geomatys_contribution_misconceptions_about_NaN
. Personnally that didn't help me to draw a conclusion on your question.
Maybe except that both suck in different ways.
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the gdal-dev
mailing list