1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
# Copyright Crown and Cartopy Contributors
#
# This file is part of Cartopy and is released under the BSD 3-clause license.
# See LICENSE in the root of the repository for full licensing details.
import matplotlib as mpl
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
def show(projection, geometry):
orig_backend = mpl.get_backend()
plt.switch_backend('tkagg')
if geometry.geom_type == 'MultiPolygon' and 1:
multi_polygon = geometry
import cartopy.mpl.path as cpath
pth = cpath.shapely_to_path(multi_polygon)
patch = mpatches.PathPatch(pth, edgecolor='none', lw=0, alpha=0.2)
plt.gca().add_patch(patch)
for polygon in multi_polygon.geoms:
line_string = polygon.exterior
plt.plot(*zip(*line_string.coords), marker='+', linestyle='-')
elif geometry.geom_type == 'MultiPolygon':
multi_polygon = geometry
for polygon in multi_polygon.geoms:
line_string = polygon.exterior
plt.plot(*zip(*line_string.coords),
marker='+', linestyle='-')
elif geometry.geom_type == 'MultiLineString':
multi_line_string = geometry
for line_string in multi_line_string.geoms:
plt.plot(*zip(*line_string.coords),
marker='+', linestyle='-')
elif geometry.geom_type == 'LinearRing':
plt.plot(*zip(*geometry.coords), marker='+', linestyle='-')
if 1:
# Whole map domain
plt.autoscale()
elif 0:
# The left-hand triangle
plt.xlim(-1.65e7, -1.2e7)
plt.ylim(0.3e7, 0.65e7)
elif 0:
# The tip of the left-hand triangle
plt.xlim(-1.65e7, -1.55e7)
plt.ylim(0.3e7, 0.4e7)
elif 1:
# The very tip of the left-hand triangle
plt.xlim(-1.632e7, -1.622e7)
plt.ylim(0.327e7, 0.337e7)
elif 1:
# The tip of the right-hand triangle
plt.xlim(1.55e7, 1.65e7)
plt.ylim(0.3e7, 0.4e7)
plt.plot(*zip(*projection.boundary.coords), marker='o',
scalex=False, scaley=False, zorder=-1)
plt.show()
plt.switch_backend(orig_backend)
|