Description of parameters of GDAL SetGeoTransform

The geotransform is used to convert from map to pixel coordinates and back using an affine transformation. The 3rd and 5th parameter are used (together with the 2nd and 4th) to define the rotation if your image doesn't have 'north up'.

But most images are north up, and then both the 3rd and 5th parameter are zero.

The affine transform consists of six coefficients returned by GDALDataset::GetGeoTransform() which map pixel/line coordinates into georeferenced space using the following relationship:

Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2)
Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5)

See the section on affine geotransform at: https://gdal.org/tutorials/geotransforms_tut.html


I did do like below code. As a result I was able to do same with SetGeoTransform.

# new file
dst = gdal.GetDriverByName('GTiff').Create(OUT_PATH, xsize, ysize, band_num, dtype)

# old file
ds = gdal.Open(fpath)
wkt = ds.GetProjection()
gcps = ds.GetGCPs()

dst.SetGCPs(gcps, wkt)
...
dst.FlushCache()
dst = Nonet

Tags:

Gdal