[gdal-dev] Gdal doesn't see NaN values as NoData?

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Wed May 5 15:10:47 PDT 2021


>> a) Why does gdalinfo not report the presence of nan? Meaning: how do I know when I will need to invoke (b)?
>
>It doesn't report nan as the nodata value, because the file lacks the GDAL_NODATA tiff tag set at "nan". So the issue is on the producer side.

Ok, noted. I will try trace this backward and report there.


>> b) What do I need to do so that applications will use nan as nodata?
>
>	gdalwarp -dstnodata nan ...
>
>or if you want to remap nan to some other value
>
>	gdalwarp -dstnodata -9999 ...

Wonderful, thank you.

>In most cases, you'd need to explicitly add the srcnodata value with 
>-srcnodata nan , but nan is a special case. When gdalwarp finds a pixel 
>at NaN value, be it the declared nodata value or not, it assumes this is 
>nodata, hence you can omit -srcnodata nan. Wouldn't be true if 0 or some 
>other value was the undeclared nodata  value.

Hmmm. Part of me expects gdalwarp to then record it found and used undeclared nodata by setting the "nodata=nan" in the metadata. Regardless thanks for this important detail.

-Matt


More information about the gdal-dev mailing list