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).

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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