I am trying to crop an image using GDAL python.
I have tried using both gdal.Warp
and gdal.Translate
, and both keep bringing the same result.
I have an image that I have orthorectified using gdal.Warp
called imortho
. I want to select a small window from this image:
window = [-76.845, 39.054, -76.805, 39.012]
This is what I have tried:
gdal.Translate(outfile, imortho, projWin = window)
The size of the square is accurate, but almost half of the image has no data. The original image has data on the entirety of the window (and beyond).
When I try to do the same, specifying the projWinSRS
option the result is the same.
When I try to use the gdal.Warp
function instead:
gdal.Warp(outfile, imortho, outputBounds = window)
The result is similar (even though the nodata region is in a different place). See the image:
Is this a bug or is there anything I'm not doing correctly to crop the data?