Free Weather On Your Website Via The National Weather Service’s RSS Feeds
A lot of Web sites like to offer current weather observations, and there are several providers out there that will either give you a free, pre-sized box for that contains that information — provided you let them splash their logo all over it and link the image back to them, driving traffic away from your site — or charge you a premium for the information.
But the U.S. government provides this information for you, free of charge, via XML and RSS. That’s right: No matter where you are in the United States, with a little bit of programming, you can make your own current observations weather box, free of charge, and customize it to look exactly how you want it to look.
The National Weather Service offers these free feeds through its Web site, at http://www.weather.gov/current_obs/. Since I’m in Maine, I’ll be using the Maine RSS / XML feed info to discuss this.
As the link above notes, all you need to do is select your state from the pull-down menu on that page. If you do that for Maine, you’ll see on the results page that there are 18 different NWS reporting stations for the state, from Frenchville in northern Aroostook County to Sanford in the southwest.
You’ll also notice that there are two types of feeds: An RSS feed and an XML feed. The difference is that the RSS feed basically contains a one-sentence summary of the current weather conditions at the station, while the XML feed is more like a database query: It contains specific fields and values for things such as temperature, wind speed / direction, pressure, etc.
I’ll be concentrating more on the XML feed as I discuss how to use this data to make your own weather feed on your site, but I’ll quickly cover using the RSS feeds, too. In future articles, I’ll be demonstrating how to parse these feeds, in PHP 4, PHP 5 and ASP.NET / VB.NET. I’ll offer source code as well; right now, I am waiting for soureforge.net to approve project space for me on their servers. Once that’s up and running, I will go ahead and post the follow-up articles.
You’ll also notice, on the NWS site, that additional feeds are provided, the most interesting of which is the National Digital Forecast Database XML feed. That is provided as a Web Service / SOAP product. I’ll address using the NDFD XML after I talk about using the current observations, since it’s a lot harder to consume a Web Service than parse an XML feed, and I want to make sure we cover the topic for pretty much all skill levels.
















November 7th, 2006 14:21
[...] As previously promised, I’ve finally gotten around to producing a PHP script to help people with limited programming skills use the National Weather Service’s free current observations XML feeds. [...]
November 11th, 2006 19:02
[...] In a previous article, I noted that I would provide ASP.NET code to consume the National Weather Service’s XML current observation feeds. Here it is. [...]