from fiona import collection import matplotlib.pyplot as plt from descartes import PolygonPatch from matplotlib.collections import PatchCollection from itertools import imap from matplotlib.cm import get_cmap cm = get_cmap('Dark2') figure, axes = plt.subplots(1) source_path = "./shapefiles/world_countries_boundary_file_world_2002" with collection(source_path, 'r') as source: patches = imap(PolygonPatch, (record['geometry'] for record in source) axes.add_collection( PatchCollection ( patches, cmap=cm, linewidths=0.1 ) ) axes.set_xlim(-180,+180) axes.set_ylim(-90,90) plt.show()
Note that this suggests that polygons, MultiPolygons can be processed in a similar way with
map(PolygonPatch, MultiPolygon(record['geometry']))
source share