0

Did anyone here face the issue of inconsistent worldfile generated from gdal_translate?

Currently I am converting a geotiff file to jpeg, in the process also generate a prj and jgw file (jgw file is generate by just changing the extension of the wld file)

Command: gdal.Translate(output_dir + output_fn + ".jpg", src_img, outputType=gdal.GDT_Byte, format='JPEG', bandList = [1,2,3], creationOptions = ['worldfile=yes','quality=75'])

In the worldfile, the origin (top left coordinates had been shifted after gdal_translate) is not consistent with what is display in gdalinfo.

This is causing all my polygon to shift.

Below is an illustration:

Using gdalinfo

Coordinate System is:
PROJCS["WGS 84 / UTM zone 47N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.2572235604902,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",99],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","32647"]]
**Origin = (772184.037661706795916,92403.612661796985776)**
**Pixel Size = (0.027623100000000,-0.027623099999999)**
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=JPEG
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  772184.038,   92403.613) (101d26'44.02"E,  0d50' 6.85"N)
Lower Left  (  772184.038,   91893.939) (101d26'44.01"E,  0d49'50.27"N)
Upper Right (  772850.307,   92403.613) (101d27' 5.55"E,  0d50' 6.84"N)
Lower Right (  772850.307,   91893.939) (101d27' 5.54"E,  0d49'50.26"N)
Center      (  772517.172,   92148.776) (101d26'54.78"E,  0d49'58.56"N)

gdal_translate worldfile

**0.0276231000**
0.0000000000
0.0000000000
**-0.0276231000**
**772184.0514732568**
**92403.5988502470**
  • Origin in the world file is at the centre of the top-left pixel while for GDAL the origin it at the top-left corner of the top-left pixel. I believe that there are old questions and answers about this in gis.stackexchange and it belongs to the need-to-know things in raster GIS. Notice also that gdalinfo reports the net area covered by the pixels so the lower-right value stands for the lower-right corner of the lower-right pixel. – user30184 Aug 27 '18 at 6: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.