[Gdal-dev] how to write out a tiff file using GDAL?

Frank Warmerdam warmerdam at pobox.com
Fri Dec 4 10:59:52 EST 2009


cudars wrote:
> I have read GDAL API Tutorial.
> The Tutorial wrote "Once the dataset is successfully created, all
> appropriate metadata and raster data must be written to the file. What this
> is will vary according to usage, but a simple case with a projection,
> geotransform and raster data is covered here."
> 
> If I want to write more metadata other than projection, geotransform etc,
> What should I do?
> I want to keep the original tiff file metadata and add my metadata to the
> new create tiff.

Cudars,

In C++ you could do:

   poDstDS->SetMetadata( poSrcDS->GetMetadata() );

to copy the primary metadata domain from GDALDataset poSrcDS to GDALDataset
poDstDS.  You could also loop over the bands, and do something similar with
them.  You can then set individual metadata items with the SetMetadataItem()
method.

   poDstDS->SetMetadataItem( "TIFFTAG_DOCUMENTNAME", "My first english essay" );

Generic metadata is access via the metadata methods on the GDALMajorObject
from which both GDALDataset and GDALRasterBand are derived.

   http://www.gdal.org/classGDALMajorObject.html

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