Created
September 5, 2012 14:04
-
-
Save sgillies/3637104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from descartes import PolygonPatch | |
from functools import reduce | |
import json | |
import urllib | |
data = urllib.urlopen("https://raw.github.com/gist/3634233/4de4c6de1cd0edbea410cc32bfcc7cbe90a78b44/tlv.json").read() | |
f = json.loads(data) | |
g = f.copy() | |
g['geometry']['coordinates'] = [f['geometry']['coordinates']] | |
# Code below renders the polygon with pylab in IPython's notebook | |
BLUE = '#6699cc' | |
def draw(axes, item): | |
"""Given matplotlib axes and a geometric item, adds the item as a patch | |
and returns the axes so that reduce() can accumulate more patches.""" | |
axes.add_patch( | |
PolygonPatch(item, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)) | |
axes.autoscale(tight=False) | |
return axes | |
figsize(8, 8) | |
reduce(draw, [g['geometry']], gca()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment