Simple Sinatra app to parse the GeoRSS feed of ShakeMaps from USGS
JavaScript Ruby
Latest commit 19a8c13 Nov 15, 2010 @sabman Renamed readme.
Failed to load latest commit information.
app/controllers first commit Apr 26, 2010
public updated the link to the blog Apr 26, 2010
views updated the link to the blog Apr 26, 2010
README.textile added for deploying to heroku Apr 26, 2010
shakemaps.rb first commit Apr 26, 2010


Since Haiti I have been doing a lot of reading on disaster response and recovery. Today I needed to load a GeoRSS feed from USGS. They publish the location of earthquakes as a GeoRSS feed. They also publish a product called ShakeMaps. This is a fantastic product since it provides a map of the actual “ground shaking” a not just the simplistic magnitude and epicentre. Creating a ShakeMap is a function of local geology, epicentre, magnitude and many other variables. You can read about it here. ShakeMap are thus much more useful from a disaster response and recovery point-of-view. For example if you have the necessary data on geology and population exposure you can run a model that simulates an earthquake over a region to predict the likely effect on the population.

Getting back to the GeoRSS – the ShakeMap feed allows us to integrate this into any web mapping application thus creating interesting mashups. E.g. overlaying it with socio-economic or population exposure or vulnerability data to show the simulation results I mention above.

Okay so I’ll show you how to set up a GeoRSS feed parser using Sinatra. Here is the ShakeMap as GeoRSS Feed. You will need ruby and sinatra installed.

Here is the code for the routes in sinatra:

require 'rubygems'
require 'sinatra'
require 'open-uri'
get '/' do
  haml :shakemaps
get '/proxy' do
  open params["url"]

When the client hits the our root url (/) we will render the OpenLayers map with the USGS ShakeMap. We may also want to let people add other feeds.

So in our shakemaps.rb the first route is to the root. This is pretty simple, when the root of the app is hit the server renders the shakemaps haml template. The haml template loads our javascript to render the OpenLayers map. This javascript also calls the shakemap GeoRSS feed via a proxy. The proxy is needed because OpenLayers which is a javascript library isn’t allowed cross-site-server calls. The proxy is where the second method in shakemaps.rb comes along. It looks for the parameter url at the end of the URI and simply opens it. This is the GeoRSS XML feed. Finally there is a form allowing us to point to other GeoRSS feeds.