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

Matt Fearon singlespeed10 at gmail.com
Tue Mar 25 18:17:53 EDT 2008


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?

thanks,
Matt


*code snipet*
driver = gdal.GetDriverByName( 'GTiff')
dst_ds = driver.Create(outfile, xsize, ysize, nbands, datatype)

meta='+proj=utm +zone=50 +north +datum=WGS84 +units=meters'
srs = osr.SpatialReference()
status=1
status=srs.SetFromUserInput(meta)
status=dst_ds.SetProjection(srs.ExportToWkt())

gdalinfo outfile.tif

Driver: GTiff/GeoTIFF
Size is 13700, 13300
Coordinate System is:
PROJCS["WGS 84 / UTM zone 50N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.2572235629972,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    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["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","32650"]]
Metadata:
  AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,13300.0)
Upper Right (13700.0,    0.0)
Lower Right (13700.0,13300.0)
Center      ( 6850.0, 6650.0)
Band 1 Block=13700x1 Type=Float32, ColorInterp=Gray


More information about the gdal-dev mailing list