[FWTools] How do I populate the Geotiff Citation fields

Frank Warmerdam warmerdam at pobox.com
Thu Apr 12 21:13:36 EDT 2007


Ron Hunt wrote:
> I want to create and populate two GeoTiff Metadata fields, PCSCitation 
> and GTCitation with ASCII strings. I see how I can create GDAL metadata 
> with the gdal_translate -mo option. How do I get these to be in the 
> Geotiff metadata and not create a GDAL one?

Ron,

The GeoTIFF writing code basically tries to write these citations from
the names for the PROJCS and GEOGCS in the well known text coordinate
system description.  This code is responsible.

/* -------------------------------------------------------------------- */
/*      Try to write a citation from the main coordinate system         */
/*      name.                                                           */
/* -------------------------------------------------------------------- */
     if( poSRS->GetRoot() != NULL
         && poSRS->GetRoot()->GetChild(0) != NULL
         && poSRS->IsProjected() )
     {
         GTIFKeySet( psGTIF, GTCitationGeoKey, TYPE_ASCII, 0,
                     poSRS->GetRoot()->GetChild(0)->GetValue() );
     }

/* -------------------------------------------------------------------- */
/*      Try to write a GCS citation.                                    */
/* -------------------------------------------------------------------- */
     OGR_SRSNode *poGCS = poSRS->GetAttrNode( "GEOGCS" );

     if( poGCS != NULL && poGCS->GetChild(0) != NULL )
     {
         GTIFKeySet( psGTIF, GeogCitationGeoKey, TYPE_ASCII, 0,
                     poGCS->GetChild(0)->GetValue() );
     }

So basically, given a Well known text description like the following:

PROJCS["UTM Zone 11, Northern Hemisphere",
     GEOGCS["WGS 84",
         DATUM["WGS_1984",
             SPHEROID["WGS 84",6378137,298.257223563],
             TOWGS84[0,0,0,0,0,0,0]],
         PRIMEM["Greenwich",0],
         UNIT["degree",0.0174532925199433]],
     PROJECTION["Transverse_Mercator"],
     PARAMETER["latitude_of_origin",0],
     PARAMETER["central_meridian",-117],
     PARAMETER["scale_factor",0.9996],
     PARAMETER["false_easting",500000],
     PARAMETER["false_northing",0],
     UNIT["Meter",1]]

It would write "UTM Zone 11, Northern Hemisphere" and "WGS 84"
as the citations.

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



More information about the FWTools mailing list