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

Even Rouault even.rouault at spatialys.com
Tue Feb 13 09:06:37 PST 2018


On mardi 13 février 2018 17:45:18 CET Christoph Paulik wrote:
> 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
> 

Christoph,

The issue was that the numeric arguments were converted to string with str(x) which doesn't 
use enough precision. I've fixed this in trunk per
https://trac.osgeo.org/gdal/changeset/41472

You could workaround the issue by using:

gdal.Translate('out.tif', 'src.tif', options = '-tr 0.0888888888888888888 
0.0888888888888888888 -projwin -180.0 -20.0 -179 -21')

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180213/a9a0588d/attachment.html>


More information about the gdal-dev mailing list