[gdal-dev] gdal_translate a VRT built on top of GeoTIFFs with NaN

Even Rouault even.rouault at spatialys.com
Mon May 2 05:49:15 PDT 2016


Le lundi 02 mai 2016 14:37:39, Daniele Romagnoli a écrit :
> Hi List,
> 
> I have a reprojectiion tool which creates GeoTIFFs with NoData = NaN.
> I'm creating couple of GeoTIFFs with partially overlapping areas where
> GeoTIFF1 has NaNs in a region and GeoTIFF2 has proper values in the same
> overlapping region and viceversa (GeoTIFF2 has some NaN area while GeoTIFF1
> has valid pixels for same area).
> I have built a VRT on top of them and then translated into a single
> GeoTIFF. However, the result has NaN in those regions.
> I was hoping that the area containing NaNs would have been ignored instead,
> in favor of proper values from the other file.
> Is there any flag, properties or suggestions to make it working?
> 
> If I configure the reprojection tool to write NoData = -9999 and then use
> gdalbuildvrt -srcnodata -9999, things are working fine.
> So I'm just wondering if the same can be achieved dealing with NaN instead
> of custom values.

Daniele,

You didn't mention which GDAL version you use. It is possible that support for 
NaN as a nodata value in gdalbuildvrt & the VRT driver was fixed at some point. 
From a quick test with trunk, it works  (works with 1.11 branch as well):

$ cat in1.asc
ncols        3
nrows        3
xllcorner    440720.000000000000
yllcorner    3750120.000000000000
cellsize     60.000000000000
NODATA_value    nan
 1.0 1.0 1.0
 1.0 nan 1.0
 1.0 1.0 1.0

$ cat in2.asc
ncols        3
nrows        3
xllcorner    440720.000000000000
yllcorner    3750120.000000000000
cellsize     60.000000000000
NODATA_value    nan
 nan nan nan
 nan 2.0 nan
 nan nan nan

$ gdalbuildvrt nan.vrt in1.asc in2.asc

$ gdal_translate nan.vrt /vsistdout/ -of aaigrid
ncols        3
nrows        3
xllcorner    440720.000000000000
yllcorner    3750120.000000000000
cellsize     60.000000000000
NODATA_value    nan
      1      1      1
      1      2      1
      1      1      1


Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list