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

2018-02-13 Thread Even Rouault
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) ifxres = 0.89
>ouput Pixel_size = 0.889000
> 2) ifxres = 0.09
>ouput Pixel_size = 0.088900
> 3) ifxres = 0.008889
>ouput Pixel_size = 0.008890
> 4) ifxres = 0.000889
>ouput Pixel_size = 0.000889
> 

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.088 
0.088 -projwin -180.0 -20.0 -179 -21')

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

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

2018-02-13 Thread Christoph Paulik

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) ifxres = 0.89
   ouput Pixel_size = 0.889000
2) ifxres = 0.09
   ouput Pixel_size = 0.088900
3) ifxres = 0.008889
   ouput Pixel_size = 0.008890
4) ifxres = 0.000889
   ouput Pixel_size = 0.000889

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.000,-20.0137490)
Pixel Size = (0.0888900,-0.0888900)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.000, -20.000) (180d 0' 0.00"W, 20d 0' 0.00"S)
Lower Left  (-180.000, -20.978) (180d 0' 0.00"W, 20d58'40.00"S)
Upper Right (-179.022, -20.000) (179d 1'20.00"W, 20d 0' 0.00"S)
Lower Right (-179.022, -20.978) (179d 1'20.00"W, 20d58'40.00"S)
Center  (-179.511, -20.489) (179d30'40.00"W, 20d29'20.00"S)
Band 1 Block=11x11 Type=Int16, ColorInterp=Gray
  NoData Value=0

$ gdal_translate -tr 0. 0.8 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.000,-20.0137490)
Pixel Size = (0.889,-0.889)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.000, -20.000) (180d 0' 0.00"W, 20d 0' 0.00"S)
Lower Left  (-180.000, -20.889) (180d 0' 0.00"W, 20d53'20.00"S)
Upper Right (-179.111, -20.000) (179d 6'40.00"W, 20d 0' 0.00"S)
Lower Right (-179.111, -20.889) (179d 6'40.00"W, 20d53'20.00"S)
Center  (-179.556, -20.444) (179d33'20.00"W, 20d26'40.00"S)
Band 1 Block=1x1 Type=Int16, ColorInterp=Gray
  NoData Value=0



testwarpsmall.py
Description: Binary data

-- 

---
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


signature.asc
Description: PGP signature
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev