|
| 1 | +""" |
| 2 | +Highlight country, continent and state polygons |
| 3 | +----------------------------------------------- |
| 4 | +The :meth:`pygmt.Figure.coast` method can highlight country polygons |
| 5 | +via the ``dcw`` parameter. It accepts the country code or full |
| 6 | +country name and can draw its borders and add a color to its landmass. |
| 7 | +It's also possible to define multiple countries at once by separating |
| 8 | +the indiviudal names with commas. |
| 9 | +""" |
| 10 | + |
| 11 | +# sphinx_gallery_thumbnail_number = 1 |
| 12 | + |
| 13 | + |
| 14 | +import pygmt |
| 15 | + |
| 16 | +fig = pygmt.Figure() |
| 17 | + |
| 18 | +fig.coast( |
| 19 | + region=[-12, 32, 34, 72], |
| 20 | + # Lambert Azimuthal Equal Area lon0/lat0/horizon/width |
| 21 | + projection="A10/52/25/6c", |
| 22 | + land="gray", |
| 23 | + water="white", |
| 24 | + frame="afg", |
| 25 | + dcw=[ |
| 26 | + # Great Britain (country code) with seagrean land |
| 27 | + "GB+gseagreen", |
| 28 | + # Italy with a red border |
| 29 | + "IT+p0.5p,red3", |
| 30 | + # Spain with a magenta dashed border |
| 31 | + "ES+p0.5p,magenta4,-", |
| 32 | + # Romania with a black dotted border |
| 33 | + "RO+p0.75p,black,.", |
| 34 | + # Germany with orange land and a blue border |
| 35 | + "DE+gorange+p0.5p,dodgerblue4", |
| 36 | + # France (full country name) with a steelblue border |
| 37 | + "France+p0.5p,steelblue", |
| 38 | + # Norway, Sweden and Finland (multiple countries) with pink |
| 39 | + # land and pink3 borders |
| 40 | + "Norway,Sweden,Finland+gpink+p0.2p,pink3", |
| 41 | + ], |
| 42 | +) |
| 43 | + |
| 44 | +fig.show() |
| 45 | + |
| 46 | +############################################################################### |
| 47 | +# Entire continents can also be highlighted by adding ``"="`` in |
| 48 | +# front of the continent code to differentiate it from a country code. |
| 49 | + |
| 50 | +fig = pygmt.Figure() |
| 51 | + |
| 52 | +fig.coast( |
| 53 | + region="d", |
| 54 | + projection="H10c", |
| 55 | + land="gray", |
| 56 | + water="white", |
| 57 | + frame="afg", |
| 58 | + dcw=[ |
| 59 | + # Europe |
| 60 | + "=EU+gseagreen", |
| 61 | + # Africa |
| 62 | + "=AF+gred3", |
| 63 | + # North America |
| 64 | + "=NA+gmagenta4", |
| 65 | + # South America |
| 66 | + "=SA+gorange", |
| 67 | + # Asia |
| 68 | + "=AS+gdodgerblue4", |
| 69 | + # Oceania |
| 70 | + "=OC+gtomato", |
| 71 | + # Antarctica |
| 72 | + "=AN+ggray30", |
| 73 | + ], |
| 74 | +) |
| 75 | + |
| 76 | +fig.show() |
| 77 | + |
| 78 | +############################################################################### |
| 79 | +# If available, states/territories of a country can be highlighted, too. |
| 80 | + |
| 81 | +fig = pygmt.Figure() |
| 82 | + |
| 83 | +fig.coast( |
| 84 | + region=[-130, -70, 24, 52], |
| 85 | + projection="L-100/35/33/45/12c", |
| 86 | + land="gray", |
| 87 | + shorelines="1/0.5p,gray30", |
| 88 | + borders=["1/0.8p,gray30", "2/0.2p,gray30"], |
| 89 | + frame=True, |
| 90 | + dcw=[ |
| 91 | + # Texas with orange fill |
| 92 | + "US.TX+gorange", |
| 93 | + # Kentucky with blue outline |
| 94 | + "US.KY+p1p,blue", |
| 95 | + ], |
| 96 | +) |
| 97 | + |
| 98 | +fig.show() |
0 commit comments