Closed ldesousa closed 2 years ago
I created a vector file with the Homolosine counter-domain to verify the resulting raster against it. There are more replications than I initially reported. Screen captures from GRASS:
This raster does not have Antarctica, but it is possible similar issues happen there.
I can't replicate with the small_world.tif from https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/data/small_world.tif
wget https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/data/small_world.tif?raw=true -O in.tif
gdalwarp in.tif out.tif -overwrite -t_srs "+proj=igh"
Here is an example with a public dataset. Ran on Ubuntu 18.04 with GDAL 2.2.3:
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_sovereignty.zip
unzip ne_10m_admin_0_sovereignty.zip
gdal_rasterize -a NE_ID -a_nodata 0 -tr 0.01 0.01 -of GTiff ne_10m_admin_0_sovereignty.shp ne_10m_admin_0_sovereignty.tif
gdalwarp -overwrite -s_srs EPSG:4326 -t_srs '+proj=igh +lat_0=0 +lon_0=0 +datum=WGS84 +units=m +no_defs' -co "COMPRESS=DEFLATE" -te -20037500 -6729000 20037250 8600750 -tr 250 250 ne_10m_admin_0_sovereignty.tif ne_10m_admin_0_sovereignty_Goode.tif
OK so the problem is that the invert IGH projection doesn't check that the input (x,y) is in the domain of output of the forward path. Consequently points like -6367850 7051386 and 629308.892412171 7051386 map to the same point in (long,lat): -17.139173815748 65.529497121681
The solution is to run gdalwarp with "--config CHECK_WITH_INVERT_PROJ TRUE", so that after the inverse projection, a forward one is re-done.
The fact that the issue appears at some particular combination of input/output size/resolution comes from the chunking done by gdalwarp. Some chunks that are mostly outside the validity domain are rejected, wheras others that have mostly inside are still processed, but with those potential out of domain points.
I confirm that the parameter --config CHECK_WITH_INVERT_PROJ TRUE
produces correct results. However, transformations made with programmes like QGis or GRASS produce the errors reported initially, meaning that the software is not conceived for cases like this.
Should perhaps the CHECK_WITH_INVERT_PROJ
parameter be true by default?
I have made a function to reproject any large global layer to Goode Homolosine in parallel (see latlon2gh function. This seems to produce OK result (see: https://doi.org/10.5281/zenodo.3355006) although there are still some smaller pixels on the upper edges of the map that get lost in reprojection. I've used GDAL 2.3.1 for processing. Thanks @ldesousa for preparing the domain for GH and for sharing!
it should probably the job of PROJ's inverse Interrupted Goode Homolosine implementation to reject points that are outside the validity domain. If the issue still matters, please raise the issue on PROJ side
Expected behavior and actual behavior.
I am reprojecting a global raster that is defined on constant longitude-latitude intervals into Goode's projection (no datum shift). Things go more less well, but Iceland and eastern Greeland appear twice, and ouside the counter-domain of Goode's projection:
Steps to reproduce the problem.
This is what
gdal_info
says about the input raster:This is the
gdalwarp
command:And
gdalinfo
on the output:Operating system
Ubuntu 16.04 64 bit Ubuntu 18.04 64 bit
GDAL version and provenance
2.2.2 version from ubuntugis-unstable PPA (Ubuntu 16.04) 2.2.3 version from ubuntugis-unstable PPA (Ubuntu 18.04)
Extra
The end result is the same with either version 2.2.2 and 2.2.3. However, with 2.2.2
gdalwarp
takes about 5 minutes to complete and produces a 50 MB tif, whereas 2.2.3 takes 75 min and produces a 700 MB tif.If you wish to obtain the input file, please contact me by e-mail or through gitter.im.