[gdal-dev] Howto change geo transform parameters in dataset.

Frank Warmerdam warmerdam at pobox.com
Mon May 31 13:13:00 EDT 2010

Oliver Eichler wrote:
> Hi,
> I would like to change the offset of a referenced file. I use
> GDALDataset::GetGeoTransform(adfGeoTransform) to read the current
> settings. I change adfGeoTransform[0] and adfGeoTransform[3] and use
> GDALDataset::SetGeoTransform(adfGeoTransform) to replace the old settings.
> Of course that does not work. GDAL tells me that this works only on
> newly created datasets. Well ok. 2nd try:


What file format are you working with?  Your approach is appropriate,
but not all drivers support changing metadata like the geotransform after
the file has been created on disk.

> I use GDALDriver::CreateCopy() to create new dataset and to copy all
> data. But even with the new copy
> GDALDataset::SetGeoTransform(adfGeoTransform) fails for the  same reason.

File formats that only support CreateCopy(), and not Create(), will
generally require you to set the appropriate geotransform in the source
dataset before calling CreateCopy().  It is possible to create a
virtual dataset wrapped around your real source, and set the updated
geotransform on that.  This is how gdal_translate handles stuff like
changing the coordinate system, and geotransform.

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