MCPcopy Create free account
hub / github.com/OSGeo/PROJ / plotproj

Function plotproj

docs/plot/plot.py:202–310  ·  view source on GitHub ↗

Plot map.

(plotdef, geoms, outdir)

Source from the content-addressed store, hash-verified

200
201
202def plotproj(plotdef, geoms, outdir):
203 """Plot map."""
204 axes = plt.axes()
205
206 box = Box(
207 plotdef["lonmin"], plotdef["latmin"], plotdef["lonmax"], plotdef["latmax"]
208 )
209
210 # Filter to geometries that intersect the bounds; evaluate intersection
211 geoms = geoms[box.intersects(geoms)]
212 geoms = box.intersection(geoms)
213
214 # Add extra vertices for segments greater than 2.0 degrees
215 geoms = shapely.segmentize(geoms, 2.0)
216
217 # Reproject all geometries
218 geoms = project_geoms(geoms, proj_string=plotdef["projstring"])
219
220 # Plot each geometry
221 for geom in geoms:
222 if plotdef["type"] == "poly":
223 patch = patch_from_polygon(geom, color=COLOR_LAND, zorder=0)
224 axes.add_patch(patch)
225 else:
226 plot_with_interruptions(
227 axes,
228 *geom.xy,
229 color=COLOR_COAST,
230 linewidth=0.5,
231 delta_cut=plotdef.get("delta_cut", 1e100),
232 )
233
234 # Plot frame
235 frame = np.array(
236 [
237 parallel(plotdef["latmin"], plotdef["lonmin"], plotdef["lonmax"]),
238 parallel(plotdef["latmax"], plotdef["lonmin"], plotdef["lonmax"]),
239 ]
240 )
241 frame = project_geoms(frame, proj_string=plotdef["projstring"])
242 for line in frame:
243 plot_with_interruptions(
244 axes,
245 *line.xy,
246 color="black",
247 linestyle="-",
248 delta_cut=plotdef.get("delta_cut", 1e6),
249 )
250
251 # Plot graticule
252 graticule = build_graticule(
253 plotdef["lonmin"],
254 plotdef["lonmax"],
255 plotdef["latmin"],
256 plotdef["latmax"],
257 )
258 graticule = project_geoms(graticule, proj_string=plotdef["projstring"])
259 for line in graticule:

Callers 1

mainFunction · 0.85

Calls 8

project_geomsFunction · 0.85
plot_with_interruptionsFunction · 0.85
parallelFunction · 0.85
build_graticuleFunction · 0.85
meridianFunction · 0.85
intersectionMethod · 0.80
intersectsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected