[gdal-dev] Remapping nodata

Even Rouault even.rouault at spatialys.com
Thu Jan 7 01:42:03 PST 2016


Le jeudi 07 janvier 2016 08:54:17, Julien Michel a écrit :
> Well, maybe this is a little off topic for the gdal mailing list, but I
> recently had to deal with the same case, and wrote a small application
> in Orfeo ToolBox (>5.2) to do exactly that: map NaN to a real no data
> value [1]. So if you need this really quick, and can afford bringin
> another (quite big) tool in your workflow, here is a workaround.
> 
> In the long term, this would be a nice addition to gdal_translate
> capabilities.

This can actually be done with gdalwarp.

$ cat in.asc
ncols        2
nrows        2
xllcorner    440720
yllcorner    3751200
cellsize     60
NODATA_value nan
 nan 123.0
 115 132

$ gdalwarp in.asc out.tif  -dstnodata 0 -overwrite

(if using trunk please update to the latest revision as I just discovered and 
fixed a bug for this very particular case (float32 and 0 as target nodata). 2.0 
works fine)

$ gdal_translate out.tif /vsistdout/ -of aaigrid
ncols        2
nrows        2
xllcorner    440720.000000000000
yllcorner    3751200.000000000000
cellsize     60.000000000000
NODATA_value  0
 0.0 123
 115 132

(you likely need a recent enough GDAL version so that NaN is correctly dealt 
with)


> 
> Regards,
> 
> Julien
> 
> [1]
> https://www.orfeo-toolbox.org/CookBook/CookBooksu61.html#x85-1900004.1.7
> 
> Le 06/01/2016 23:59, Brad Hards a écrit :
> > I'm working on the geopackage elevation extension experiment, and trying
> > to produce some GeoTIFF tiles that get inserted into sqlite.
> > 
> > I need to remap the existing nodata (nan) to some other value that I can
> > insert into a sqlite table as a number (say zero).
> > 
> > I had a long explanation of what I'm doing here, but it is actually
> > explained in the docs: "Note that, if the input dataset has a nodata
> > value, this does not cause pixel values that are equal to that nodata
> > value to be changed to the value specified with this option. "
> > 
> > Is there an easy way to do that conversion?
> > 
> > Brad
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev

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


More information about the gdal-dev mailing list