Debian Codegraph @

examples/with-descartes.py

raw
1 import subprocess
2
3 from matplotlib import pyplot
4 from descartes import PolygonPatch
5
6 import fiona
7
8 # Set up the figure and axes.
9 BLUE = '#6699cc'
10 fig = pyplot.figure(1, figsize=(6, 6), dpi=90)
11 ax = fig.add_subplot(111)
12
13 with fiona.drivers():
14
15 # For each feature in the collection, add a patch to the axes.
16 with fiona.open('docs/data/test_uk.shp', 'r') as input:
17 for f in input:
18 ax.add_patch(
19 PolygonPatch(
20 f['geometry'], fc=BLUE, ec=BLUE, alpha=0.5, zorder=2 ))
21
22 # Should be able to get extents from the collection in a future version
23 # of Fiona.
24 ax.set_xlim(-9.25, 2.75)
25 ax.set_ylim(49.5, 61.5)
26
27 fig.savefig('test_uk.png')
28
29 subprocess.call(['open', 'test_uk.png'])