[gdal-dev] Insert non-standard tag into geotiff header

Frank Warmerdam warmerdam at pobox.com
Mon Jun 6 13:15:30 EDT 2011


On 11-06-03 04:20 PM, marine88 wrote:
> HI,
> I am new to this and was asked if I could insert a custom tag into the
> geotiff header. I have no clue on how to do this is this even possible?
...
 > Thanks for the reply.  Is this only in C?  Or is there something in C#?  Also
 > I get the function but...not quite sure how to utlize this, is there some
 > tutorial or example code I can go by?

Richard,

The SetMetadataItem() method referenced by Chaitanya is also available
in C. It can be invoked on the dataset as a whole or on a particular
band object.  The C function is:

CPLErr GDALSetMetadataItem 	( 	GDALMajorObjectH  	hObject,
		const char *  	pszName,
		const char *  	pszValue,
		const char *  	pszDomain	
	)

http://www.gdal.org/gdal_8h.html#c92aec63371e9e4b0121276406f0bd8d

So you can pass a GDALDatasetH or GDALRasterBandH as "hObject".  Yhe
pszDomain should normally be NULL unless you want to set metadata items.

Note that this puts the metadata items all into one custom GDAL tag for
metadata (which will be an XML formatted string with the various metadata
items).  There is no mechanism in GDAL to write out an arbitrary new TIFF
tag.   If you need to do that you are pretty much reduced to using the
libtiff API.

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