Slide 46
Slide 46 text
Rtree
Libraries
>>> states.items()[:1]
[(1, {'attributes': {'abbrev': 'ME', 'id': 1,
'name': u'Maine'}, 'geom': })]
>>> idx = index.Index()
>>> for id, state in states.iteritems():
... idx.insert(id, state['geom'].bounds)
>>> pt = Point(-76.6, 39.2, -76.6, 39.2)
>>> res = list(idx.intersection((pt.x, pt.y,
pt.x, pt.y)))
>>> res
[18, 78]
>>> states[18]
{'attributes': {'abbrev': None, 'id': 18, 'name':
u'Maryland'}, 'geom': }