[gdal-dev] small gdal_translate modification

Frank Warmerdam warmerdam at p...
Sun Oct 6 19:05:42 EDT 2002


qjhart wrote:

> Hello,
> 
> I needed a method to insert metadata into a gdal_translate. 
> Specifically, something like: 
> 
> gdal_translate -mo 'TIFFTAG_DOCUMENTNAME=c37118a2ne_v1' \ 
> -mo 'TIFFTAG_IMAGEDESCRIPTION=TINEMAHA NE - 1:12000 DOQ-Q' \
> -mo 'TIFFTAG_SOFTWARE=CaSIL Processed' \
> -mo 'TIFFTAG_DATETIME=1998:04:15 00:00:00' \
> -co TFW=YES \
> c3711863.nws.866031 c37118a2ne_v1.tif
> 
> I'm including my mods to gdal_translate, though really this is a
> feature request I guess. Mods below don't allow multi-valued tags,
> and don't check TIFFTAG format. They overwirte source metadata of
> same KEY.

Quinn,

I have added the feature but used some slightly different mechanisms
internally. In particular, I only set the metadata on the output dataset,
or the intermediate virtual dataset (when used).

Your code sets the metadata on the source dataset that is to be copied, and
for now that works OK but it violates my mental model, which is that only the
driver should be able to set metadata on a read-only data source, and that this
metadata would represent the actual contents of the source dataset. While
currently nothing stops you from adding metadata to the source dataset
eventually something might, so that approach should be avoided.

Also your mechanism provides no means to add metadata to raster bands,
just at the dataset level. But it is an improvement over nothing.

A more generalized mechanism for altering things like metadata, georeferencing
and so on, is to use gdal_translate to copy a file to a "virtual" file via
the "VRT" format. Then edit the XML virtual file and add/fix anything
necessary, like metadata, then copy the virtual file again with gdal_translate.

Thanks for your contribution.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
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