(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
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
-Sn
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.
#!/usr/bin/env bash
# GMT EXAMPLE 25
#
# Purpose: Display distribution of antipode types
# GMT modules: set, grdlandmask, grdmath, grd2xyz, math, grdimage, coast, legend
# Unix progs: rm
#
# Create D minutes global grid with -1 over oceans and +1 over land
gmt begin ex25
D=30
gmt grdlandmask -Rg -I${D}m -Dc -A500 -N-1/1/1/1/1 -r -Gwetdry.nc
# Manipulate so -1 means ocean/ocean antipode, +1 = land/land, and 0 elsewhere
gmt grdmath -fg wetdry.nc DUP 180 ROTX FLIPUD ADD 2 DIV = key.nc
# Calculate percentage area of each type of antipode match.
gmt grdmath -Rg -I${D}m -r Y COSD 60 $D DIV 360 MUL DUP MUL PI DIV DIV 100 MUL = scale.nc
gmt grdmath key.nc -1 EQ 0 NAN scale.nc MUL = tmp.nc
gmt grd2xyz tmp.nc -s -ZTLf > key.b
ocean=$(gmt math -bi1f -Ca -S key.b SUM UPPER RINT =)
gmt grdmath key.nc 1 EQ 0 NAN scale.nc MUL = tmp.nc
gmt grd2xyz tmp.nc -s -ZTLf > key.b
land=$(gmt math -bi1f -Ca -S key.b SUM UPPER RINT =)
gmt grdmath key.nc 0 EQ 0 NAN scale.nc MUL = tmp.nc
gmt grd2xyz tmp.nc -s -ZTLf > key.b
mixed=$(gmt math -bi1f -Ca -S key.b SUM UPPER RINT =)
# Generate corresponding color table
gmt makecpt -Cblue,gray,red -T-1.5/1.5/1 -N
# Create the final plot and overlay coastlines
gmt set FONT_ANNOT_PRIMARY +10p FORMAT_GEO_MAP dddF
gmt grdimage key.nc -JKs180/22c -Bx60 -By30 -BWsNE+t"Antipodal comparisons" -nn
gmt coast -Wthinnest -Dc -A500
# Place an explanatory legend below
gmt legend -DJBC+w15c -Y-0.5c -F+pthick <<- END
N 3
S 0.4c s 0.5c red 0.25p 0.75c Terrestrial Antipodes [$land %]
S 0.4c s 0.5c blue 0.25p 0.75c Oceanic Antipodes [$ocean %]
S 0.4c s 0.5c gray 0.25p 0.75c Mixed Antipodes [$mixed %]
END
rm -f *.nc key.*
gmt end show

Global distribution of antipodes.¶