GenericMappingTools / gmt

The Generic Mapping Tools
https://www.generic-mapping-tools.org
Other
843 stars 350 forks source link

Add support for interrupted map projections #6137

Open PaulWessel opened 2 years ago

PaulWessel commented 2 years ago

Description of the desired feature

This issue started with a GMT Julia discussion. It is a lot of work to implement an interrupted projection in GMT since the map boundaries are all over and lines and polygons should be properly clipped across these many boundaries. The alternative solution is to have a single module that just handles interrupted projections (piecemeal) and accepts the gmt command(s) you wish to replicate across the pieces. I have implemented this scheme (more or less) as a bash script, and can easily make maps like these. Here is the land-centric Goode interrupted homolosine projection of our 2m DEM with shading:

homolosine_land

Similarly, here are crustal ages on the ocean-centric Goode interrupted homolosine projection:

homolosine_ocean

These are always and only global maps with one of these configurations. There are also other interrupted projections like the interrupted sinusoidal, for instance. I imagine a syntax like this:

gmt interrupt -Tprojtype/scale -F"cmd1; cmd2; ..." [ -O -K -P -X -Y]

where one can stack more than one command to be replicated at the various pieces involved. Above for the DEM, the cmd was just "grdimage @earth_relief_02m -I+d". Given the unlimited number of cmd one can stack, one can plot grids or images and overlay land or data points, lines, or polygons or text or vectors etc.

Implementing this will be simple; the alternative is hard. Pinging @GenericMappingTools/core for feedback. For instance, not clear to me how the -F option would be wrapped in the externals.

joa-quim commented 2 years ago

Hmm, why can't we have that interrupt module work silently under the hood and on surface we would still use grdimage -J<good_homolosine_land[_lon_0]>/scale ... and the same for other modules?

PaulWessel commented 2 years ago

Yes, perhaps. Each plotting module would need to have a check if interrupted projection, then set up a call to gmtinterrupt and exit. That call would itself make 3-12 calls to the same plot module with different -R -J settings per slice. I will explore that. This would mean no interrupt module per se, just a function that behaves like one.

PaulWessel commented 2 years ago

Accepting suggestions for how to specify these projections. I think you said igh_o was the ocean one and there is no igh_l for land? Is there an igh for non-interrupted homolosine where one can specify the central longitude? What about interrupted sinusoidal (3 pieces like in the old GMT logo)? If there are official proj4 codes for these then we should use them. If not then we need to make something up. While I may not have the time or energy to try to implement dymaxion and Spielhaus projection, we should expect these codes as well eventually.

joa-quim commented 2 years ago

See After all they have the land version too. It's the igh. The non-interrupted is good. There's nothing in that page on other Interrupted projections. They all accept lon_0.

PaulWessel commented 2 years ago

Thanks, I like the coastlines that wraps cross the map for the ocean case (!). So no dymexian or interrupted sinusoidal means we need syntax for those.

anbj commented 2 years ago

Could you explain what a 'interrupted map projection' is?

Esteban82 commented 2 years ago

Maybe what wikipedia says?

anbj commented 2 years ago

Thanks Esteban. How the heck did I not manage to google this before I asked.