[gdal-dev] Handling nodata values

Frank Warmerdam warmerdam at pobox.com
Fri Jun 25 11:09:14 EDT 2010


NopMap wrote:
> 
> Hi!
> 
> I am trying to create contour lines (and later hillshading) from CGIAR data.
> They use –32768 as a nodata value for sea areas which results in tremendous
> cliffs if the data is processed by gdal_contour as it is.

Nop,

If the nodata value is not recognised by GDAL you can indicate it explicitly
to gdal_contour using the -snodata switch.

eg.

gdal_contour -snodata -32768 ...

> I am looking for a way to replace this nodata value in the geotiffs by a
> simple 0 value for sea level. It would be great to save the result as a
> geotiff that can be used as input for contours, hillshading and maybe other
> calculations. Unfortunately I could not figure out which tool to use for
> this and how to do it.

The "val_repl.py" (value replace) sample script can be used for this purpose.

   http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/val_repl.py

eg.

python val_reply.py -innd -32768 -outnd 0 in.tif out.tif

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list