(25) Global distribution of antipodes

As promised in Example (23) All great-circle paths lead to Rome, we will study antipodes. The antipode of a point at is the point at . We seek an answer to the question that has plagued so many for so long: Given the distribution of land and ocean, how often is the antipode of a point on land also on land? And what about marine antipodes? We use grdlandmask and grdmath to map these distributions and calculate the area of the Earth (in percent) that goes with each of the three possibilities. To make sense of our grdmath equations below, note that we first calculate a grid that is +1 when a point and its antipode is on land, -1 if both are in the ocean, and 0 elsewhere. We then seek to calculate the area distribution of dry antipodes by only pulling out the nodes that equal +1. As each point represent an area approximated by where the term’s actual dimension depends on, we need to allow for that shrinkage, normalize our sum to that of the whole area of the Earth, and finally convert that ratio to percent. Since the , terms appear twice in these expressions they cancel out, leaving the somewhat intractable expressions below where the sum of for all is known to equal

In the end we obtain a funny-looking map depicting the antipodal distribution as well as displaying in legend form the requested percentages. Note that the script is set to evaluate a global 30 minute grid for expediency (D = 30), hence several smaller land masses that do have terrestrial antipodes do not show up. If you want a more accurate map you can set the parameter D to a smaller increment (try 5 and wait a few minutes).

The call to grdimage includes the interp=:n to suspend interpolation and only return the value of the nearest neighbor. This option is particularly practical for plotting categorical data, like these, that should not be interpolated.

using GMT, Printf

Gwetdry = grdlandmask(region=:global360, inc="30m", res=:crude, area=500, N="-1/1/1/1/1", reg=true);
# Manipulate so -1 means ocean/ocean antipode, +1 = land/land, and 0 elsewhere
Gkey = gmt("grdmath -fg ? DUP 180 ROTX FLIPUD ADD 2 DIV =", Gwetdry);
# Calculate percentage area of each type of antipode match.
Gscale = gmt("grdmath -Rg -I30m -r Y COSD 60 30 DIV 360 MUL DUP MUL PI DIV DIV 100 MUL =");
Gtmp   = gmt("grdmath -fg ? -1 EQ 0 NAN =", Gkey);
Gtmp  *= Gscale;

key    = grd2xyz(Gtmp, skip_NaN=true, onecol=:TLf);
ocean  = gmt("gmtmath -bi1f -Ca -S ? SUM UPPER RINT =", key);
Gtmp   = gmt("grdmath -fg ? 1 EQ 0 NAN =", Gkey)
Gtmp  *= Gscale;
key    = grd2xyz(Gtmp, skip_NaN=true, onecol=:TLf)
land   = gmt("gmtmath -bi1f -Ca -S ? SUM UPPER RINT =", key)
Gtmp   = gmt("grdmath -fg ? 0 EQ 0 NAN", Gkey)
Gtmp  *= Gscale;
key    = grd2xyz(Gtmp, skip_NaN=true, onecol=:TLf)
mixed  = gmt("gmtmath -bi1f -Ca -S ? SUM UPPER RINT =", key)

# Generate corresponding color table
C = makecpt(color="blue,gray,red", range=(-1.5,1.5,1))
# But unfortunately this palette is not correct, so lets patch it
C.colormap[1,1:2] .= 0;   C.colormap[1,3] = 1;
C.colormap[3,2:3] .= 0;   C.colormap[3,1] = 1;

# Create the final plot and overlay coastlines
gmtset(FONT_ANNOT_PRIMARY="+8p", FORMAT_GEO_MAP=:dddF)
grdimage(Gkey, proj=(name=:EckertVI, center=180), frame=(axes=:WsNE, title="Antipodal comparisons"),
         xaxis=(annot=60,), yaxis=(annot=30,), yshift=3, interp=:n)
coast!(shore=:thinnest, area=500)

# Place an explanatory legend below
legend!(pos=(anchor=:BC, width=10), box=(pen=:thick,), yshift=-1.0, par=(:FONT_ANNOT_PRIMARY,7),
    text_record(["N 3"
    string("S 0.3 s 0.25 red  0.25p 0.5 Terrestrial Antipodes [", round(Int, land.data[1]), " %]", )
    string("S 0.3 s 0.25 blue 0.25p 0.5 Oceanic Antipodes [", round(Int, ocean.data[1]), " %]", )
    string("S 0.3 s 0.25 gray 0.25p 0.5 Mixed Antipodes [", round(Int, mixed.data[1]), " %]", )]), show=true)