Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using gdalwarp with the -te option and it doesn't appear to be working like I expected.

I'm running a command like:

gdalwarp -of GTiff -te -180 -90 180 90 -tr 0.1 0.1 -t_srs EPSG:4326 input.tif output.tif

or

gdalwarp -of GTiff -te -180.0 -90.0 180.0 90.0 -tr 0.1 0.1 -t_srs EPSG:4326 input.tif output.tif

But when I run gdalinfo after executing gdalwarp I get this:

Upper Left  (-180.0000000,  90.0000000) (180d 0'0.00"W, 90d 0'0.00"N)
Lower Left  (-180.0000000, -89.9903092) (180d 0'0.00"W, 89d59'25.11"S)
Upper Right ( 179.9806183,  90.0000000) (179d58'50.23"E, 90d 0'0.00"N)
Lower Right ( 179.9806183, -89.9903092) (179d58'50.23"E, 89d59'25.11"S)
Center      (  -0.0096908,   0.0048454) (  0d 0'34.89"W,  0d 0'17.44"N)

How can I create a geotiff where the extents with the following values?

Upper Left  (-180.0000000,  90.0000000) (180d 0'0.00"W, 90d 0'0.00"N)
Lower Left  (-180.0000000, -90.0000000) (180d 0'0.00"W, 90d 0'0.00"S)
Upper Right ( 180.0000000,  90.0000000) (180d 0'0.00"E, 90d 0'0.00"N)
Lower Right ( 180.0000000, -90.0000000) (180d 0'0.00"E, 90d 0'0.00"S)
Center      (   0.0000000,   0.0000000) (  0d 0'0.00"W,  0d 0'0.00"N)
share|improve this question
    
I was able to force the extents to the desired values by running a second gdalwarp command with -te and no other options. gdalwarp -te -180 -90 180 90 output.tif correctExtents.tif. I still think I should be able to do this in one command though. –  Alex B Aug 27 '11 at 19:44
add comment

1 Answer 1

I think you need to specify the -ts option rather than the -tr option. In other words, you know the exact size of your output array, so specify it rather than let GDAL calculate it. Otherwise, gdalwarp tries to calculate it (note sure where this is in the codebase, but see this.

share|improve this answer
    
So are you saying using "-tr" makes the -"te" not strictly enforced? –  Alex B Aug 27 '11 at 19:43
    
I had the same problem some time ago, and it appeared to be a rounding error (some conditional testing on something that was being rounded off). I just got around it by specifying the actual size of the array. Not sure whether this still applies to current versions of the library tho' –  Jose Aug 29 '11 at 13:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.