Putting the “Geo” into GeoRSS

I’m a big fan of georss. It’s a simple architecture that allows you to bind geographic information (i.e. latitude/longitude coordinates) into any XML content (e.g. Atom/RSS feeds).

If you’ve already got spatial data, you can use GeoRSS to create a syndicated feed of spatial information, such as follows:

<rss xmlns:georss="http://www.georss.org/georss"
     xmlns:gml="http://www.opengis.net/gml"
     version="2.0">
  <channel>
    <title>SQL Server GeoRSS Feed</title>
    <description>This feed contains information about some fictional properties for sale in order to demonstrate how to syndicate spatial data using the GeoRSS format. </description>
    <link>http://www.beginningspatial.com</link>
	<pubDate>Wed, 1 Oct 2008</pubDate>
    <item>
      <title>Pilgrims Way, Chew Stoke, Somerset</title>
      <description>Grade II Listed former Rectory, with magnificent architectural features and stunning gardens. £750000.00</description>
      <link>http://www.example.com/1</link>
      <pubDate>2008-09-01T17:00:00Z</pubDate>
      <georss:where>
        <gml:Point>
          <gml:pos>51.35494 -2.635765</gml:pos>
        </gml:Point>
      </georss:where>
    </item>
    <item>
     ...
    </item
  </channel>
</rss>

What’s nice about using the GeoRSS format is that it’s recognised and already supported by lots of applications. For example, suppose you wanted to plot the items contained in the above feed on Google Maps. No problem – just go to the http://maps.google.com site and type in the URL address of the GeoRSS feed in the search box. (Alternatively, pass it directly in the q parameter of the URL, like this: http://maps.google.com/?q=http://www.beginningspatial.com/georss_example.xml ).

The resulting map automatically plots all the items in the GeoRSS feed on the map, as well as listing them in the sidebar

image

However, what if you don’t have spatial data for each item in your feed ready to hand? What if’ you’ve got a regular RSS feed of items related to places on the earth, but not in a geocoded format? No problem, geonames offers a rssToGeoRSS service that basically geocodes each item in an rss feed – automatically adding the georss elements for you.

To use the service, specify the georss format you want (e.g. GML) and pass the URL of your regular RSS feed in the feedUrl parameter as in the following syntax.

http://ws.geonames.org/rssToGeoRSS?feedUrl=http://feeds.bbci.co.uk/news/world/rss.xml&georss=gml

The resulting output will then contain the requested <georss> elements for each item. You can then go on to pass this GeoRSS feed to another service. So, to view a map displaying a feed of the BBC top World News items on a Google Map, you can first pass the BBC news feed onto geonames, and then the resulting GeoRSS straight on to Google maps, like this:

http://maps.google.com/?q=http://ws.geonames.org/rssToGeoRSS?feedUrl=http://feeds.bbci.co.uk/news/world/rss.xml&georss=gml

(Note that sometimes the geonames free servers get overloaded with requests, so you might not always get a response. Just try again later.)

About these ads
This entry was posted in Spatial and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s