Andrew Trice
Real-World Rich Internet Applications
Friday March 27, 2009
Consuming Public Data - This Time It's The Weather
The amount of free, public data on the internet is amazing. There are so many good data providers everywhere, all waiting to be consumed by a rich interface, and mashed-up into something that is relevant and useful. In a previous post, I showed the possibilities of integrating one of the many free map providers with census data in a geographic dashboard. This time around I decided to take a different approach; rather than looking back at past/historical data, what can we visualize that is happening right now?
The news this morning showed pictures of the massive flooding that is happening in the midwest, so I decided to see what I can find about any real-time weather alerts or radar. Being a map & weather nerd, I knew exactly where to look... www.weather.gov. The national weather service's radar data is available as gif images, which can be consumed in any RIA, and actual breaking-weather alerts are available per state in RSS feeds, complete with a cross-domain policy allowing them to be consumed in your own applications. Note: Be sure to check their terms of use before using this in a commercial application.
Here's an example of what I was able to quickly throw together in a Flex interface. It allows you to select a US state, and will show all recent weather alerts for that state, based on the data feeds from the national weather service. Not only that, it will show you the current national weather radar. If you click on it, you can even zoom into a higher-resolution version of the weather map (it defaults to the center of the country when you zoom in).
Check it out in the screenshots below. Just click on an image to try it out for yourself.
You can check it out for yourself at http://cynergysystems.com/blogs/blogs/andrew.trice/weather
Consuming the data is simple. You can hard-reference the URL for the weather map in any basic Image component. That URL will always be the most recently available weather map.
<mx:Image
source="http://radar.weather.gov/Conus/RadarImg/latest_Small.gif" />
And consuming the weather alerts is just as easy. You just need to use an HTTPService to load the RSS feed into your application.
<mx:HTTPService
id="weatherAlertService"
url="http://www.weather.gov/alerts-beta/{ statesCombobox.selectedItem.abbreviation }.atom"
result="onResult(event)"
fault="onFault(event)"
resultFormat="e4x"/>
The only trick is to make sure that you are using the appropriate namespaces to access the data within the feed:
//namespaces used in weather alert Atom feeds
namespace cap = "urn:oasis:names:tc:emergency:cap:1.1";
use namespace cap;
namespace atom = "http://www.w3.org/2005/Atom";
use namespace atom;
namespace ha = "http://www.alerting.net/namespace/index_1.0";
use namespace ha;
It's as easy as that. Enjoy!








