Coverage for pyguymer3/geo/add_GSHHG_map_underlay.py: 6%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.3, created at 2025-08-16 08:31 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def add_GSHHG_map_underlay( 

5 ax, 

6 /, 

7 *, 

8 background = True, 

9 debug = __debug__, 

10 fov = None, 

11 iceOcean = True, 

12 islandLake = True, 

13 lakeLand = True, 

14 landOcean = True, 

15 linewidth = 0.5, 

16 onlyValid = False, 

17 pondIsland = True, 

18 repair = False, 

19 resolution = "i", 

20): 

21 """Add an underlay to a Cartopy axis from the `Global Self-Consistent 

22 Hierarchical High-Resolution Geography dataset` 

23 

24 Parameters 

25 ---------- 

26 ax : cartopy.mpl.geoaxes.GeoAxesSubplot 

27 the axis 

28 background : bool, optional 

29 add background 

30 debug : bool, optional 

31 print debug messages 

32 fov : None or shapely.geometry.polygon.Polygon, optional 

33 clip the plotted shapes to the provided field-of-view to work around 

34 occaisional MatPlotLib or Cartopy plotting errors when shapes much 

35 larger than the field-of-view are plotted 

36 iceOcean : bool, optional 

37 add ice-ocean boundaries 

38 islandLake : bool, optional 

39 add island-lake boundaries 

40 lakeLand : bool, optional 

41 add lake-land boundaries 

42 landOcean : bool, optional 

43 add land-ocean boundaries 

44 linewidth : float, optional 

45 the linewidth to draw the boundaries with 

46 onlyValid : bool, optional 

47 only return valid Polygons (checks for validity can take a while, if 

48 being called often) 

49 pondIsland : bool, optional 

50 add pond-island boundaries 

51 repair : bool, optional 

52 attempt to repair invalid Polygons 

53 resolution : str, optional 

54 the resolution of the boundaries 

55 

56 Notes 

57 ----- 

58 There is one argument relating to the `Global Self-Consistent Hierarchical 

59 High-Resolution Geography dataset <https://www.ngdc.noaa.gov/mgg/shorelines/>`_ : 

60 

61 * *resolution*. 

62 

63 There are five resolutions to choose from: 

64 

65 * crude ("c"); 

66 * low ("l"); 

67 * intermediate ("i"); 

68 * high ("h"); and 

69 * full ("f"). 

70 

71 Copyright 2017 Thomas Guymer [1]_ 

72 

73 References 

74 ---------- 

75 .. [1] PyGuymer3, https://github.com/Guymer/PyGuymer3 

76 """ 

77 

78 # Import sub-functions ... 

79 from ._add_background import _add_background 

80 from ._add_coastlines import _add_coastlines 

81 

82 # ************************************************************************** 

83 

84 # Add background ... 

85 if background: 

86 # Water ... 

87 _add_background( 

88 ax, 

89 debug = debug, 

90 ) 

91 

92 # Add ice-ocean boundaries ... 

93 if iceOcean: 

94 # Ice ... 

95 _add_coastlines( 

96 ax, 

97 debug = debug, 

98 edgecolor = "blue", 

99 facecolor = "aliceblue", 

100 fov = fov, 

101 levels = (5,), 

102 linestyle = "solid", 

103 linewidth = linewidth, 

104 onlyValid = onlyValid, 

105 repair = repair, 

106 resolution = resolution, 

107 zorder = 1.5, 

108 ) 

109 

110 # Add land-ocean boundaries ... 

111 if landOcean: 

112 # Land ... 

113 _add_coastlines( 

114 ax, 

115 debug = debug, 

116 edgecolor = "green", 

117 facecolor = "darkkhaki", 

118 fov = fov, 

119 levels = (1,), 

120 linestyle = "solid", 

121 linewidth = linewidth, 

122 onlyValid = onlyValid, 

123 repair = repair, 

124 resolution = resolution, 

125 zorder = 1.6, 

126 ) 

127 

128 # Snow ... 

129 _add_coastlines( 

130 ax, 

131 debug = debug, 

132 edgecolor = "white", 

133 facecolor = "snow", 

134 fov = fov, 

135 levels = (6,), 

136 linestyle = "solid", 

137 linewidth = linewidth, 

138 onlyValid = onlyValid, 

139 repair = repair, 

140 resolution = resolution, 

141 zorder = 1.6, 

142 ) 

143 

144 # Add lake-land boundaries ... 

145 if lakeLand: 

146 # Lake ... 

147 _add_coastlines( 

148 ax, 

149 debug = debug, 

150 edgecolor = "none", 

151 facecolor = "lightblue", 

152 fov = fov, 

153 levels = (2,), 

154 linestyle = "solid", 

155 linewidth = linewidth, 

156 onlyValid = onlyValid, 

157 repair = repair, 

158 resolution = resolution, 

159 zorder = 1.7, 

160 ) 

161 

162 # Add island-lake boundaries ... 

163 if islandLake: 

164 # Island ... 

165 _add_coastlines( 

166 ax, 

167 debug = debug, 

168 edgecolor = "green", 

169 facecolor = "darkkhaki", 

170 fov = fov, 

171 levels = (3,), 

172 linestyle = "solid", 

173 linewidth = linewidth, 

174 onlyValid = onlyValid, 

175 repair = repair, 

176 resolution = resolution, 

177 zorder = 1.8, 

178 ) 

179 

180 # Add pond-island boundaries ... 

181 if pondIsland: 

182 # Pond ... 

183 _add_coastlines( 

184 ax, 

185 debug = debug, 

186 edgecolor = "none", 

187 facecolor = "lightblue", 

188 fov = fov, 

189 levels = (4,), 

190 linestyle = "solid", 

191 linewidth = linewidth, 

192 onlyValid = onlyValid, 

193 repair = repair, 

194 resolution = resolution, 

195 zorder = 1.9, 

196 )