[gdal-dev] object methods for adding metadata to Geotiff

Frank Warmerdam warmerdam at pobox.com
Tue Mar 25 18:26:16 EDT 2008


Matt Fearon wrote:
> Hi,
> 
> I am trying to assign projection information and other metadata to a
> converted Geotiff file via osr.SpatialReference. My original raw
> binary file has this information separate from the data. I would like
> to attach this information to the new Geotiff using python/GDAL. I am
> able to input a subset of projection information with the following
> object methods. However, how could I add information on pixel size and
> corner coordinates and other metadata? Is there an object method
> though python for doing this - or would have to use the gdal_translate
> utility?

Matt,

You should use the SetGeoTransform() method on the dataset to set the
origin and pixel size.  For instance for an image with the top left
corner at 250000mN, 3730000mE and a pixel size of 10m x 10m I would
use:

  dst_ds.SetGeoTransform( (250000,10,0,3730000,0,-10) )

Read up on the GDAL data model for more detail on the geotransform if
you are interested.

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 gdal-dev mailing list