[gdal-dev] Python Interfaces to gdal warp and gdal translate behave differently than command line

Christoph Paulik cpaulik at vandersat.com
Tue Feb 13 08:45:18 PST 2018


Hi,

In my original email I had a small (300KB) test geotiff attached but
this was rejected by the mailing list. So here the original email again:

If we warp or translate the a GeoTIFF using the Python API
in the attached python file then the output pixel precision is
truncated (even when 15 digtis precison is specified) depending on the
number of 0 preceding the first non-zero number after the first digit (see
testwarpsmall.py).
The system calls work as expected though.

Tested on gdal 2.2.3.

Example:
1) if                    xres = 0.88888888888889
       ouput Pixel_size = 0.88888888889000
2) if                    xres = 0.08888888888889
       ouput Pixel_size = 0.08888888888900
3) if                    xres = 0.00888888888889
       ouput Pixel_size = 0.00888888888890
4) if                    xres = 0.00088888888889
       ouput Pixel_size = 0.00088888888889

In detail:

$ python testwarpsmall.py 

$ gdalinfo output_test.tif

Driver: GTiff/GeoTIFF
Files: output_test.tif
Size is 11, 11
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 = (-180.000000000000000,-20.000000000137490)
Pixel Size = (0.088888888888900,-0.088888888888900)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.0000000, -20.0000000) (180d 0' 0.00"W, 20d 0' 0.00"S)
Lower Left  (-180.0000000, -20.9777778) (180d 0' 0.00"W, 20d58'40.00"S)
Upper Right (-179.0222222, -20.0000000) (179d 1'20.00"W, 20d 0' 0.00"S)
Lower Right (-179.0222222, -20.9777778) (179d 1'20.00"W, 20d58'40.00"S)
Center      (-179.5111111, -20.4888889) (179d30'40.00"W, 20d29'20.00"S)
Band 1 Block=11x11 Type=Int16, ColorInterp=Gray
  NoData Value=0

$ gdal_translate -tr 0.8888888888888888 0.88888888888888888 input_test.tif output_test.tif 
Input file size is 375, 375
0...10...20...30...40...50...60...70...80...90...100 - done.

$ gdalinfo output_test.tif                                                                
Driver: GTiff/GeoTIFF
Files: output_test.tif
Size is 1, 1
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 = (-180.000000000000000,-20.000000000137490)
Pixel Size = (0.888888888888889,-0.888888888888889)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.0000000, -20.0000000) (180d 0' 0.00"W, 20d 0' 0.00"S)
Lower Left  (-180.0000000, -20.8888889) (180d 0' 0.00"W, 20d53'20.00"S)
Upper Right (-179.1111111, -20.0000000) (179d 6'40.00"W, 20d 0' 0.00"S)
Lower Right (-179.1111111, -20.8888889) (179d 6'40.00"W, 20d53'20.00"S)
Center      (-179.5555556, -20.4444444) (179d33'20.00"W, 20d26'40.00"S)
Band 1 Block=1x1 Type=Int16, ColorInterp=Gray
  NoData Value=0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: testwarpsmall.py
Type: application/octet-stream
Size: 277 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180213/c6270dcc/attachment.obj>
-------------- next part --------------

-- 

-------------------------------------------------------
Christoph Paulik
VanderSat // Remote Sensing Scientists
Wilhelminastraat 43a, 2011 VK, Haarlem (NL), The Netherlands
W: www.vandersat.com
PGP: 8CFC D7DF 2867 B2DC 749B  1B0A 6E3B A262 5186 A0AC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180213/c6270dcc/attachment.sig>


More information about the gdal-dev mailing list