GeoRSS Patch for Universal Feedparser
See http://code.google.com/p/feedparser/issues/detail?id=62. In a nutshell, given feeds like:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" > <entry> <georss:point>36.9382 31.1732</georss:point> </entry> </feed>
or:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" > <entry> <georss:where> <gml:Point> <gml:pos>36.9382 31.1732</gml:pos> </gml:Point> </georss:where> </entry> </feed>
the entry location, or "where" is parsed out like:
>>> import feedparser >>> feed = feedparser.parse(file) >>> entry = feed.entries[0] >>> entry['where']['type'] 'Point' >>> entry['where']['coordinates'] (31.1732, 36.9382)
Recognize that? It's GeoJSON. Simple points, lines, polygons, boxes, and GML points, linestrings, and polygons can be parsed. Since entry["where"] also provides the Python Geo Interface, you can use it immediately with Shapely:
>>> from shapely.geometry import asShape >>> shape = asShape(entry["where"]) >>> shape <shapely.geometry.point.Point object at ...> >>> shape.x 31.1732 >>> shape.y 36.9382