Skip to content

Instantly share code, notes, and snippets.

@danwild
Created November 20, 2017 05:12
Show Gist options
  • Save danwild/4ef7a4b41244fcb2ce6d686d8646b4f1 to your computer and use it in GitHub Desktop.
Save danwild/4ef7a4b41244fcb2ce6d686d8646b4f1 to your computer and use it in GitHub Desktop.
Set GeoTIFF extent/bounds with python GDAL
import gdal
in_file = '/Users/foo/Desktop/reproject/before.tif'
out_file = '/Users/foo/Desktop/reproject/after.tif'
# minX, minY, maxX, maxY
new_bounds = [
-78.0078239440917969,
-40.0333147430419922,
-66.0144157409667969,
-55.4858904266357422
]
# dest, src, options
# http://gdal.org/python/osgeo.gdal-module.html#Translate
gdal.Translate(out_file, in_file, outputBounds = new_bounds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment