[gdal-dev] Bad gdalwarp interpolation
Javier Jimenez Shaw
j1 at jimenezshaw.com
Fri Jul 26 03:26:32 PDT 2024
Hi
I do not know if there is anything wrong in GDAL. It looks like
As a workaround, you can first convert the projection to be centred at
lon=0 with something like this (I kept the same radius as the original to
minimize distortion). You can add bilinear interpolation or not, as you
wish.
gdalwarp -t_srs '+proj=eqc +a=2439400 +b=2439400 +lon_0=0.000000
+lat_0=0.000000 +x_0=0 +y_0=0 +units=m +no_defs'-overwrite
msgr_dem_low_res.tif centred.tif
And then cut with your command.
I know it is not optimal because it is converting the full image. But the
output is not blur.
Cheers,
Javier.
On Fri, 26 Jul 2024 at 09:49, Calogero Mauceri via gdal-dev <
gdal-dev at lists.osgeo.org> wrote:
> 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
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240726/368de4d2/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/368de4d2/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/368de4d2/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/368de4d2/attachment-0005.png>
More information about the gdal-dev
mailing list