How do I convert affine coordinates to lat/lng?

gdal_translate will reproject your data from whatever projection it is in to any other (in this case you want EPSG:4326) using:

gdal_translate -a_srs epsg:4326 srcfile new_file 

or you could use gdaltrasform to convert the points (and I'm sure you can access that from Python(?) too)


The geotransform is documented at https://gdal.org/user/raster_data_model.html. The idea is that you take (x,y) coordinates straight from the dataset, apply a linear transformation to get (u,v) with

u = a*x + b*y
v = c*x + d*y

(you can take this to be the definition of a linear transformation), then shift the origin by adding geotransform[0] to u and geotransform[3] to v. That gives the "affine transformation" of (x,y). It's really intended to rotate, change scale, perhaps correct a little for some skew errors, and re-situate the data-specific coordinates (x,y) to match a known coordinate system. The result is supposed to produce projected coordinates. This simply means there is a mathematical procedure taking (longitude, latitude) and turning them into the known coordinates: this is called the "projection." "Unprojecting" is doing the reverse; so, if you know which projection is needed, you apply that to the affine transformed (x,y) coordinates to get the latitude and longitude.

By the way, the values of the constants a, b, c, d are given by the 1, 2, 4, and 5 entries in the geotransform array.