Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use GDAL to set the geotransform of a new raster that I've created by following the steps outlined in the GDAL API Tutorial.

# create the new dataset
driver = gdal.GetDriverByName('GTiff')
dataset = driver.Create('test_gt.tif', 60, 60, 1, gdal.GDT_Float32)

# check the default geotransform
print dataset.GetGeoTransform()  # prints (0, 1, 0, 0, 0, 1)

# try to alter the geotransform and ensure that it has been set
print dataset.GetGeoTransform()  # prints (0, 1, 0, 0, 0, -1)

dataset = None  # closes the dataset

# Try reopening the dataset now and see if the geotransform has been set.
ds = gdal.Open('test_gt.tif')
print ds.GetGeoTransform()  #prints (0, 1, 0, 0, 0, 1)

The dataset.SetGeoTransform() documentation says that this should set the affine transformation coefficients (which, according to the dataset.GetGeoTransform() documentation is set to [0, 1, 0, 0, 0, 1] by default), but as you can see from my above code, the changes don't seem to actually take effect when I try to change them.

I've even tried flushing the new raster's cache to disk by dataset.FlushCache(), but this doesn't seem to save the changes either.

How can I have GDAL actually save the altered geotransform to disk?

I'm using GDAL version 1.6.3 installed from PyPI (via the command-line tool pip).

share|improve this question
up vote 1 down vote accepted

It turns out that this was a version-specific issue. I upgraded to GDAL version 1.8.0 and the geotransform is set correctly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.