4caster.net

defining prediction
  • Home
  • About
  • Contact

More code snippets!

October 27, 2008

If you’ve done any Googling about weather data then it should be clear that the National Weather Service provides one of the largest and most comprehensive sources of weather data.

This posting is to discuss the Current Conditions page on the NWS website and in particular the XML formatted data that is available. As I’m sure you know, one of the advantages of XML is that is strongly structures data so that there is no doubt what each element specifically is. To process XML in any language it’s always best to use inbuilt code or existing library extensions that will parse the XML data allowing you to extract just the information you require. For this example we’ll use PHP (specifically version 5) as it’s a very popular language….

So, we’ll start with working out which site we require weather data for. On the NWS page there is a link to a large zip file that covers all known weather data sites… it’s worth downloading that now.

Unfortunately you’ll just end up with approx 2800 files with obscure four character names! These are known as ICAO codes (International Civil Aviation Organization) and you’ll need to check around on the internet for a site that allows you to match a code to a particular site. For example, the Airline Industry Update site has a handy facility (as of November 2008) that allows you to match a code with a location.

So, now you should have worked out which locations you’re interested in current observations for. Let’s choose KJFK – Kennedy International Airport in New York.

Next we can see from the website that the correct xml address for each of the weather data sites looks like…

http://www.weather.gov/xml/current_obs/XXXX.xml

Of course, where XXXX is the 4 letter ICAO code! So to retrieve the current observations for JFK we’d use the following address…

http://www.weather.gov/xml/current_obs/KJFK.xml

Now if you load that into a browser you get a wealth of weather data… but not in an easily readable format. Next we need to create an XML object in our PHP application like this…

$webAddress = 'http://www.nws.noaa.gov/data/current_obs/KJFK.xml';
$xmlResults = simplexml_load_file($webAddress);

If this works, you’ll end up with a new variable called $xmlResults that you can now extract key pieces of information for. Let’s look at a couple of examples…

echo $xmlResults->weather, ' : Current Weather Summary';
echo '<br>';
echo $xmlResults->temperature_string, ' : Current Temperature Information';
echo '<br>';
echo $xmlResults->wind_string, ' : Wind Information';
echo '<br>';

Pretty great!

Comments
No Comments »
Categories
Code, Weather Data
Tags
national weather service, php, xml
Comments rss Comments rss
Trackback Trackback

Weather2U

October 25, 2008

I’m just not sure what to make of Weather2U at the moment. One of the articles on their homepage is just made up of random characters (I guess this is because people can submit articles in their own language, but I’m not sure about the point of a multilingual site?) and once every 5 minutes for the past week or so the entire site has just given a “Service Unavailable” error. One of the key criteria for a weather data provider is trust that they’ll be consistent with their provision of data and I’m just not getting that vibe!

Next, they aim to update the weather up to 4 times a day, but on the f.a.q. they say this might only happen once a day. Also, they say they “number crunch” and “decode” the data that comes from the National Weather Service, well, I guess you’d need to find out what that means as the source data is just the source data, right? And why wouldn’t you go straight to the source?

The look of the Weather2U website when it works however is excellent. If you just want to view weather forecast information online then it has well presented data (check this link out for London) and an easy to navigate interface. I’m not sure what the 300 day forecast is all about though, seems a bit ambitious!

If you want to use the Weather2U data for your own application or website… then be prepared to pay… As of October 2008 the following charges were levied for the data (available for up to 180 hours in the future)

0-1000 Requests per month – £9.95
1000-100000 Requests per month – £29.95
100000+ Requests per month – £79.95

You need to spend some time with a calculator and work out how many locations you’re interested in weather data for… as if you get 4 data inputs a day for just 50 locations then you’d be spending ~£359 a year… for this cost you’d need to look hard at the value add that Weather2U are adding to the original National Weather Service data.

Overall Weather2U provides exactly what you’d want for a weather data provider, long term forecast data, lots of locations, well formatted data…. but this is tempered by the unreliability of the site, long term costs and an outstanding question about the value add of their data over and above the National Weather Service. We’ll have to keep a close eye on the site!

Comments
No Comments »
Categories
Weather Data
Tags
weather2u, xml
Comments rss Comments rss
Trackback Trackback

About

4caster.net aims to consolidate information about weather data as well as analyse and predict weather forecasts more accurately based on historical data.

Archives

  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008

Tags

bbc c# coding data geo::metar metar metcheck national weather service perl php pxweather rss rssweather site information weather weather2u Weather Data world meteorological organization world weather information service xml
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox