[Gdal-dev] How to add a NODATA flag to GTiff data?

Frank Warmerdam warmerdam at pobox.com
Thu Sep 16 13:53:04 EDT 2004

Thom DeCarlo wrote:
> Hello,
> I've got several IFSAR DEM files in geotiff format. Each has a border of
> NODATA values (-9999.0) around the real data. My OpenSceneGraph application
> (osgdem, which uses gdal to read the input data) should understand that the
> default NODATA value is -9999, but it uses that value instead of ignoring
> it. 
> I remember that when I translated ArcGrid data, which had NODATA values
> defined in the header, to geotiff the output had a NODATA field in the
> header. My question now is how do I add the NODATA field to the geotiff file
> when translating from geotiff or Erdas Imagine format?


Currently gdal_translate has no mechanism to set a nodata value during
translation.  However, you can convert a file to VRT format, and hand
edit in a nodata value then translate that back to TIFF.

   gdal_translate -of VRT in.tif work.vrt
   edit work.vrt (add <NoDataValue>-9999</NoDataValue> tag on VRTRasterBand).
   gdal_translate work.vrt out.tif

It would be nice to have a smoother way of doing this of course.

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