2

I have to crop geotiff image, I'm using gdal assembly and I'm trying to use the gdal_translate method

If I crop my image using the -srcwin option all is fine

gdal_translate -srcwin 0 0 400 400 imageBase.tiff image_cropped.tiff

I have to manage bbox in wgs84 coordinates too, so I try to use -projwin option:

gdal_translate -projwin 103.26 23.02 103.36 22.9 imageBase.tiff image_cropped.tiff

I get the following error:

Input file size is 450, 1047
The -projwin option was used, but the geotransform is
rotated.  This configuration is not supported.

My geotiff image has been created programmatically in C# from Jpegcovnerter using tiepoints calculated with my feature image fooprint.

This is the gdalinfo over my geotiff file

Size is 450, 1047
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"]]
GeoTransform =
103.2667570026355, 0.0005062068032082341, -1.832943060114165e-007
23.02489610024383, -5.790469882757381e-005, -0.0005021561705462942
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=JPEG
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  ( 103.2667570,  23.0248961) (103d16'0.33"E, 23d 1'29.63"N)
Lower Left  ( 103.2665651,  22.4991386) (103d15'59.63"E, 22d29'56.90"N)
Upper Right ( 103.4945501,  22.9988390) (103d29'40.38"E, 22d59'55.82"N)
Lower Right ( 103.4943582,  22.4730815) (103d29'39.69"E, 22d28'23.09"N)
Center      ( 103.3805576,  22.7489888) (103d22'50.01"E, 22d44'56.36"N)
Band 1 Block=450x1047 Type=Byte, ColorInterp=Red
Band 2 Block=450x1047 Type=Byte, ColorInterp=Green
Band 3 Block=450x1047 Type=Byte, ColorInterp=Blue

I didn't implemented the class building the Tiff so it looks like my geotiff doesn't support the gdal_translate -projwin option.

Do someone have a idea about this problem and how to solve it?

  • 2
    Use gdalwarp first with -s_srs epsg:4326 -t_srs epsg:4326. – user30184 Feb 25 '16 at 21:24
  • It works because gdalwarp creates a materialized north-up, non-rotated image which is then accepted by gdal_translate for cropping. Actually you can do the same with one step by using gdalwarp with -te parameter gdal.org/gdalwarp.html. – user30184 Feb 26 '16 at 9:00
  • When i try to use -te on gdalwarp i get the error: Creating output file that is 178P x -237L. ERROR 1: Attempt to create 178x-237 dataset is illegal,sizes must be larger than zero. – Chris Tof Feb 26 '16 at 9:24
  • Show your parameters, perhaps xmin ymin xmax ymax are in wrong order and max is smaller than min. – user30184 Feb 26 '16 at 9:36
  • I tried with gdalwarp -t_srs EPSG:3857 -te 11495581.442 2635029.678 11520841.369 2568435.324 image_in.tiff image_out_bbox_proj.tiff or gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 -dstalpha te 103.2667570 23.0248961 103.36 22.9 image_in.tiff image_out.tiff an both give same error response – Chris Tof Feb 26 '16 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.