1

I have tried to clip a geotiff file using the code below:

from osgeo import gdal

miny=-10.616665787
maxy=38.558338147
minx=34.562256098
maxx=71.187259028


ds = gdal.Open(fp)
ds = gdal.Translate(out_tif, ds, projWin =  [maxx, miny, minx, maxy])
ds = None

For some reason no file is generated though, when I tried using different coordinates it worked perfectly:

from osgeo import gdal

ds = gdal.Open('original.tif')
ds = gdal.Translate('new.tif', ds, projWin = [-75.3, 5.5, -73.5, 3.7])
ds = None

Does anyone have an idea what the problem could be? This is the area I am working with: This is the area I Am working with

1 Answer 1

1

Try

ds = gdal.Translate('new.tif', ds, projWin = [-73.5, 3.7, -75.3, 5.5])

I believe your max min are inverted.

1
  • It worked for me using this format: [miny, maxx, maxy, minx] Oct 29, 2019 at 6:16

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.