Skip to content

Instantly share code, notes, and snippets.

@danwild
Created May 1, 2019 04:38
Show Gist options
  • Save danwild/3d622487fe9cbd0ef724cc2b1863909b to your computer and use it in GitHub Desktop.
Save danwild/3d622487fe9cbd0ef724cc2b1863909b to your computer and use it in GitHub Desktop.
Get GeoTIFF extent
import gdal
from gdalconst import GA_ReadOnly
data = gdal.Open('C:/Temp/myimage.tif', GA_ReadOnly)
geoTransform = data.GetGeoTransform()
minx = geoTransform[0]
maxy = geoTransform[3]
maxx = minx + geoTransform[1] * data.RasterXSize
miny = maxy + geoTransform[5] * data.RasterYSize
print (minx, miny, maxx, maxy)
data = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment