[gdal-dev] Copy / manipulate TIFF-header

Frank Warmerdam warmerdam at pobox.com
Thu Mar 4 20:16:22 EST 2010

Sigbjorn Herstad wrote:
> Hi,
> This is my first post here, but have followed the list for several
> years. I am trying to find a good way to edit a GeoTIFF-header. I have
> looked at the Python-script and listgeo and geotifcp mentioned here:
> http://lists.osgeo.org/pipermail/gdal-dev/2008-April/016752.html
> Using the Python-script updates the header of a given GeoTIFF- however
> not with all parameters I need. Using the listgeo and geotifcp a new
> file is written so update is not possible (like in the Python-script)
> - ie reprocessing all files are necessary. I am thinking about
> creating a Python-script which will update / delete / add certain
> attributes from a GeoTIFF-file, but I am not sure if this is possible?
> I do NOT want to create a new file with the changed GeoTIFF-header,
> but update the already existing one.
> Here are some of the TAGS I wish to DELETE or CHANGE:
> GTModelTypeGeoKey (Short,1):
> GTRasterTypeGeoKey (Short,1):
> GTCitationGeoKey (Ascii,8):
> GeogCitationGeoKey (Ascii,7):
> GeogAngularUnitsGeoKey (Short,1):
> ProjectedCSTypeGeoKey (Short,1):
> ProjLinearUnitsGeoKey (Short,1):
> GCS:
> Datum:
> Ellipsoid:


I do not believe it is possible to accomplish this with commandline
tools like listgeo and geotifcp, or with scripting around GDAL.

It is, in theory, possible to accomplish this using a C program
built on libtiff and libgeotiff.  But if you do this you need to be
careful to use the very latest libgeotiff code (possibly from svn) and
also very recent libtiff code (best from svn).  Rewriting a TIFF
directory is a risky process and some bugs have recently been fixed
in this regard.  Likewise, updating a GTIF (GeoTIFF tags) structure
in place is risky and recently some changes were made in libgeotiff
to support this.

Generally speaking libtiff and libgeotiff were not written with update
in place in mind which is why it is surprisingly hard.  Just how
important is it to you?

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