Coverage for pyguymer3/geo/add_GSHHG_map_underlay.py: 6%
16 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
1#!/usr/bin/env python3
3# Define function ...
4def add_GSHHG_map_underlay(
5 ax,
6 /,
7 *,
8 background = True,
9 debug = __debug__,
10 iceOcean = True,
11 islandLake = True,
12 lakeLand = True,
13 landOcean = True,
14 linewidth = 0.5,
15 onlyValid = False,
16 pondIsland = True,
17 repair = False,
18 resolution = "i",
19):
20 """Add an underlay to a Cartopy axis from the `Global Self-Consistent
21 Hierarchical High-Resolution Geography dataset`
23 Parameters
24 ----------
25 ax : cartopy.mpl.geoaxes.GeoAxesSubplot
26 the axis
27 background : bool, optional
28 add background
29 debug : bool, optional
30 print debug messages
31 iceOcean : bool, optional
32 add ice-ocean boundaries
33 islandLake : bool, optional
34 add island-lake boundaries
35 lakeLand : bool, optional
36 add lake-land boundaries
37 landOcean : bool, optional
38 add land-ocean boundaries
39 linewidth : float, optional
40 the linewidth to draw the boundaries with
41 onlyValid : bool, optional
42 only return valid Polygons (checks for validity can take a while, if
43 being called often)
44 pondIsland : bool, optional
45 add pond-island boundaries
46 repair : bool, optional
47 attempt to repair invalid Polygons
48 resolution : str, optional
49 the resolution of the boundaries
51 Notes
52 -----
53 There is one argument relating to the `Global Self-Consistent Hierarchical
54 High-Resolution Geography dataset <https://www.ngdc.noaa.gov/mgg/shorelines/>`_ :
56 * *resolution*.
58 There are five resolutions to choose from:
60 * crude ("c");
61 * low ("l");
62 * intermediate ("i");
63 * high ("h"); and
64 * full ("f").
66 Copyright 2017 Thomas Guymer [1]_
68 References
69 ----------
70 .. [1] PyGuymer3, https://github.com/Guymer/PyGuymer3
71 """
73 # Import sub-functions ...
74 from ._add_background import _add_background
75 from ._add_coastlines import _add_coastlines
77 # **************************************************************************
79 # Add background ...
80 if background:
81 # Water ...
82 _add_background(
83 ax,
84 debug = debug,
85 )
87 # Add ice-ocean boundaries ...
88 if iceOcean:
89 # Ice ...
90 _add_coastlines(
91 ax,
92 debug = debug,
93 edgecolor = "blue",
94 facecolor = "aliceblue",
95 levels = [5],
96 linestyle = "solid",
97 linewidth = linewidth,
98 onlyValid = onlyValid,
99 repair = repair,
100 resolution = resolution,
101 zorder = 1.5,
102 )
104 # Add land-ocean boundaries ...
105 if landOcean:
106 # Land ...
107 _add_coastlines(
108 ax,
109 debug = debug,
110 edgecolor = "green",
111 facecolor = "darkkhaki",
112 levels = [1],
113 linestyle = "solid",
114 linewidth = linewidth,
115 onlyValid = onlyValid,
116 repair = repair,
117 resolution = resolution,
118 zorder = 1.6,
119 )
121 # Snow ...
122 _add_coastlines(
123 ax,
124 debug = debug,
125 edgecolor = "white",
126 facecolor = "snow",
127 levels = [6],
128 linestyle = "solid",
129 linewidth = linewidth,
130 onlyValid = onlyValid,
131 repair = repair,
132 resolution = resolution,
133 zorder = 1.6,
134 )
136 # Add lake-land boundaries ...
137 if lakeLand:
138 # Lake ...
139 _add_coastlines(
140 ax,
141 debug = debug,
142 edgecolor = "none",
143 facecolor = "lightblue",
144 levels = [2],
145 linestyle = "solid",
146 linewidth = linewidth,
147 onlyValid = onlyValid,
148 repair = repair,
149 resolution = resolution,
150 zorder = 1.7,
151 )
153 # Add island-lake boundaries ...
154 if islandLake:
155 # Island ...
156 _add_coastlines(
157 ax,
158 debug = debug,
159 edgecolor = "green",
160 facecolor = "darkkhaki",
161 levels = [3],
162 linestyle = "solid",
163 linewidth = linewidth,
164 onlyValid = onlyValid,
165 repair = repair,
166 resolution = resolution,
167 zorder = 1.8,
168 )
170 # Add pond-island boundaries ...
171 if pondIsland:
172 # Pond ...
173 _add_coastlines(
174 ax,
175 debug = debug,
176 edgecolor = "none",
177 facecolor = "lightblue",
178 levels = [4],
179 linestyle = "solid",
180 linewidth = linewidth,
181 onlyValid = onlyValid,
182 repair = repair,
183 resolution = resolution,
184 zorder = 1.9,
185 )