[gdal-dev] Bad gdalwarp interpolation

Calogero Mauceri mauceri at actgate.com
Fri Jul 26 00:49:00 PDT 2024


Hi,

I'm rendering a 256x256 tile from a mercury dem. I noticed the gdalwarp is
producing a bad output when using interpolation with the following command

gdalwarp -of PNG -r bilinear -t_srs '+proj=eqc +a=2439700 +b=2439700
+lon_0=0.000000 +lat_0=0.000000 +x_0=0 +y_0=0 +units=m +no_defs' -ts 256
256 -te -958067.949620 -958067.950079 0.000460 0.000000 -overwrite
msgr_dem_low_res.tif tile.png

The output image is kind of blurred/low resolution
[image: tile.png]

On the other side, it looks good if nearest interpolation is used

gdalwarp -of PNG -t_srs '+proj=eqc +a=2439700 +b=2439700 +lon_0=0.000000
+lat_0=0.000000 +x_0=0 +y_0=0 +units=m +no_defs' -ts 256 256 -te
-958067.949620 -958067.950079 0.000460 0.000000 -overwrite
msgr_dem_low_res.tif tile.png

[image: tile.png]


The problem seems related to the fact that the right edge of the tile is
around longitude 0, while the source image is a full globe/360 degrees
image centered at 180 longitude

If I reduce the tile size to 255x255 for avoiding the 0 longitude at the
edge, then the interpolated output file looks much better

gdalwarp -of PNG -r bilinear -t_srs '+proj=eqc +a=2439700 +b=2439700
+lon_0=0.000000 +lat_0=0.000000 +x_0=0 +y_0=0 +units=m +no_defs' -ts 255
255 -te -958067.949620 -950583.044220 -7484.905400 0.000000 -overwrite
msgr_dem_low_res.tif tile_255.png

[image: tile_255.png]

Am I doing something wrong or is this a bug in GDAL?

I'm using the mercury dem from here
https://pdsimage2.wr.usgs.gov/Messenger/MESSDEM_1001/DEM/GLOBAL/IMG/
Here is a lower resolution of the same dem for testing purpose
https://
<https://pdsimage2.wr.usgs.gov/Messenger/MESSDEM_1001/DEM/GLOBAL/IMG/>
files.actgate.com/terrain/mercury/msgr_dem_low_res.tif

Thanks in advance for your help,
Calogero Mauceri

-- 
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240726/4317c904/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tile.png
Type: image/png
Size: 15874 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240726/4317c904/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tile.png
Type: image/png
Size: 8573 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240726/4317c904/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tile_255.png
Type: image/png
Size: 23708 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240726/4317c904/attachment-0005.png>


More information about the gdal-dev mailing list