OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.93k stars 2.56k forks source link

Incorrect Bilinear and cubicspline resampling at the poles #10524

Open ThalesMML opened 3 months ago

ThalesMML commented 3 months ago

What is the bug?

Firstly, "average" resampling method works correclty. But bilinear and cubicspline don't. I use GDAL to create six 8192x8192 files from 21600x10800 height map. About an area of 1024x4800 pixels on both poles are excessively blurred if bilinear or cubicspline are used instead of average.

Steps to reproduce the issue

Use bilinear and average resmaplings to create north face of cubic world map.

These are the lines I use from the guide here: https://medievalengineerswiki.com/w/Planet_Modding/Real_World_Data

gdal_translate ETOPO1_Bed_g_geotiff.tif -scale -12000 12000 0 65535 -ot UInt16 -a_srs "+proj=longlat" ETOPO1_editable.tif gdal_translate ETOPO1_editable.tif ETOPO1_editable.vrt

set PROJ_IGNORE_CELESTIAL_BODY=YES set GDAL_PAM_ENABLED=NO

gdal_translate up.vrt up.tif -co COPY_SRC_MDD=YES gdalwarp -dstnodata None -r average -wt Float32 -multi -wo SOURCE_EXTRA=100 -wo SAMPLE_GRID=YES ETOPO1_editable.vrt up.tif

Versions and provenance

Windows 11 GDAL 3.9.1 Miniconda3

Additional context

No response

mdsumner commented 3 months ago

can you show graphics of what you see in the problem areas? This is a very strange bend of the use of the warper geolocation method, using a geolocation array that might as well be an assigned transform (or bbox).

I think you can probably use QSC (Quadrilateralized Spherical Cube) instead, and give those "real world" target extents (earth radius) for this source as per the example on this page, and then convert those to suitable PNGs.

https://proj.org/en/9.4/operations/projections/qsc.html

But, if you could show some images of what you see for a face vs what you expect (I have some residual doubts I'm doing something wrong, - the faces I see in this method give approximately the same whole-world longlat as output, which can't be right - but at any rate I think you can shortcut it all using QSC with one source input rather than crafting the gnomonic faces like this).

ThalesMML commented 3 months ago

Blurred area for South pole: blurred_area This image has not enough resolution to show excessive blur, it is just for showing boundaries of blurred area which immediately stops outside of it.

North pole has blurred area same size but it is positioned right next to this.

rouault commented 3 months ago

Likely same issue as https://github.com/OSGeo/gdal/issues/10512