[Gdal-dev] Copying meta data

Matt Hanson mhanson at photon.com
Fri Nov 17 14:27:12 EST 2006

Ok, good to know.  I'm currently using ENVI as an output file now, but one of my colleagues had written a driver for our own format I haven't tested yet.  Hopefully it supports writing metadata.
So if I set GDAL_PAM_ENABLED then when I call SetMetaData, SetGeoTransform, or SetProjectionRef, then it will automatically just output it to an aux.xml file?   If I have GDAL_PAM_ENABLED set to no then will it generate an error?


From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Fri 11/17/2006 6:14 PM
To: Matt Hanson
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] Copying meta data

Matt Hanson wrote:
> Hi,
> I'm reading in a GDAL dataset, doing some processing, and outputting it to
> another file.  The output file is created using the Create() function, but I
> want to make sure I copy over all the metadata from the source.
> What do I need to do to ensure I've copied over all metadata and geographic
> info?    Is GetMetaData(), GetProjectionRef(), and GetGeoTransform() all I
> need, followed by subsequent calls to SetMetaData(), SetProjectionRef(), and
> SetGeoTransform() ?


That will mostly do the trick, with the caveat that bands can also have
metadata, so it should also be done for them.

Note that most formats do not actually support writing metadata.  GeoTIFF
and VRT being the two exceptions that come to mind.  If you want a general
mechanism to preserve metadata, coordinate systems and other auxilary
information for formats that don't normally support it, you can use
"persistent auxilary metadata" files.  Set the configuration option
GDAL_PAM_ENABLED to YES (via environment, or CPLSetConfigOption()) and
you will find that GDAL starts writing out .aux.xml files to store
info like metadata that can't be stored in the target files.

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    | President OSGeo, http://osgeo.org <http://osgeo.org/> 

More information about the Gdal-dev mailing list