[gdal-dev] decimal rounding issue when re-projecting

Jukka Rahkonen jukka.rahkonen at maanmittauslaitos.fi
Thu Jul 16 08:41:30 PDT 2015


Ramiro Marco Figuera <r.marcofiguera <at> jacobs-university.de> writes:

> 
> Hi,
> 
> I'm re-projecting (from stereographic to gnomonic) the PDS LOLA 20m/pix 
> DTMS from the lunar south pole. Im using gdalwarp like this: 'gdalwarp 
> -t_srs '+proj=gnom +lat_0=-90 +lat_ts=-90 +lon_0=0 +k=1 +x_0=0 +y_0=0 
> +a=1737400 +b=1737400 +units=m +no_defs' topo_stereo.tif topo_gnom.tif'  
> .  After that, I'm cropping the DTM to have a smaller region (200km by 
> 200km) around the pole. Then, I just use gdal_translate to export it as 
> XYZ since I need it in this format for my software and converting it to 
> kilometers instead of meters using awk.  As this is a gridded data, the 
> resolution should remain the same (20m/pixel), however when I check the 
> first entries of my xyz file the resolution is sometimes 21 m/pixel and 
> sometimes 20 m/pixel, and this happens randomly. Any clue of what may 
> cause this error? Has anyone faced the same issue?

Hi,

Gdalwarp does not try to keep resolution unchanged and I guess that the
reason is to avoid extra resampling. That your output is so close to 20
m/pix is a coincident. Varying 20/21 m pixel size in xyz file may be due to
rounding errors. Have you checked the pixel size of topo_gnom.tif with
gdalinfo? 

I would try what happens when running gdalwarp with -tr 20 20 for forcing
the output resolution to 20m/pix.

You should be able to crop and create 20 m/pixel xyz file with one run by
setting the resolution with -tr and selecting the format with -of and
defining extents with -te http://www.gdal.org/gdalwarp.html

-Jukka Rahkonen-







More information about the gdal-dev mailing list