[GIS] gdalwarp resampling problems

gdalogr

I'm trying to clip and resample a raster to match the dimensions and resolution of another raster. Here's my gdalwarp command:

    gdalwarp  -t_srs EPSG:4326 -te 102.3375307079206 14.6874037407838 107.6323189079206 10.350077240783799 -tr 0.0008332999999999999 0.0008333000000000003 -r bilinear input.tif output.tif

The extents and resolution are grabbed from the other raster and are correct. However, I get the following error:

    ERROR 1: Attempt to create 6354x-5204 dataset is illegal,sizes must be larger than zero.`

The problem is the height of the raster -5204. I've tried supplying the x and y resolution -tr with negative and positive arguments with no avail. Have also tried putting (abs) around all variables to avoid negative values. Here is the gdalinfo call for my input.tif file

    Driver: GTiff/GeoTIFF
    Files: input.tif
    Size is 6187, 8475
    Coordinate System is:
    GEOGCS["WGS 84",
DATUM["WGS_1984",
    SPHEROID["WGS 84",6378137,298.257223563,
        AUTHORITY["EPSG","7030"]],
    AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
    Origin = (97.277217688999997,23.425182730000000)
    Pixel Size = (0.002105966899941,-0.002105966899941)
    Metadata:
      AREA_OR_POINT=Area
    Image Structure Metadata:
      INTERLEAVE=BAND
    Corner Coordinates:
    Upper Left  (  97.2772177,  23.4251827) ( 97d16'37.98"E, 23d25'30.66"N)
    Lower Left  (  97.2772177,   5.5771133) ( 97d16'37.98"E,  5d34'37.61"N)
    Upper Right ( 110.3068349,  23.4251827) (110d18'24.61"E, 23d25'30.66"N)
    Lower Right ( 110.3068349,   5.5771133) (110d18'24.61"E,  5d34'37.61"N)
    Center      ( 103.7920263,  14.5011480) (103d47'31.29"E, 14d30' 4.13"N)
    Band 1 Block=6187x1 Type=Int16, ColorInterp=Gray

Any ideas how I can resolve this problem?

Best Answer

You should exchange ymin and ymax in -te (target extent).

-te 102.3375307079206 10.350077240783799 107.6323189079206  14.6874037407838