My raster is upside down, but it is too large to open as an array and rewrite it with a different geotransformation. Do you know a way to change the geotransformation without opening the raster as a numpy array?

my normal approach

import gdal
import numpy
r = gdal.Open(fileLocation)
band = r.GetRasterBand(1)  # bands start at one
b = band.ReadAsArray().astype(np.float16)
dst_ds = driver.Create(output_file, band.XSize, band.YSize, 1, gdal.GDT_Int16)
  • 1
    As far as I know, you shouldn't have to re-write the array to modify the geotransform. Have you tried omitting the last line and just modifying the geotransform that you're setting in the 2nd to last?
    – mikewatt
    Jun 8, 2021 at 17:29

1 Answer 1


This should be enough for changing the geotransformation (captured from GDAL autotests https://github.com/OSGeo/gdal/blob/master/autotest/gcore/tiff_write.py):

ds = gdal.Open('tmp/tiff57.tif', gdal.GA_Update)
ds.SetGeoTransform([100, 1, 3, 200, 3, 1])
ds = None

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.