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

Frank Warmerdam warmerdam at pobox.com
Mon May 31 14:30:32 EDT 2010


Oliver Eichler wrote:
> Am 31.05.2010 19:13, schrieb Frank Warmerdam:
>> 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:
>> Oliver,
>>
>> 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.
> 
> Hi Frank,
> 
> it's a GeoTiff. Is it possible with that format or should I have better
> have a look into the gdal_translate code?

Oliver,

Updating the geotransform should work in-place for GeoTIFF format.  This
may be a relatively new feature.  I will note that the file needs to be
open in update mode. So if opening an existing file use GA_Update as
the access mode.

Hmm, skimming the code back as far as 1.6 branch, the update of
geotransforms in geotiff seems to be supported.  I will mention that
the "is only supported on newly created GeoTIFF files" message is
still generated for read-only files.  I will correct this to a more
accurate message in trunk.

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