The weather has always fascinated me, and I actually almost became a meteorologist instead of a full-time entrepreneur. I recently had a project where I had to pull tons of weather data and display it on a website. It took tons of research to find what I was looking for, so I am presenting all my findings here 1) for my own reference, and 2) for your convenience.

This article requires in-depth know-how of parsing through vast amounts of XML data and text. If you are looking for ways to display weather information on your website w/o knowing any of this stuff, wunderground.com has plenty of weather sticker designs that you can add to your site very easily.

This source is your best bet for free, public domain, information to display on your website, desktop weather tool, etc. This is going straight to the source, which is the National Weather Service. I always recommend going to them first before some of the commercial sites, like Weather.com or Accuweather, because they get most of their weather data from the NWS anyway. This data feed provides virtually all the raw data needed to form a forecast. It doesn’t include the english-formed verbage you might be used to reading, but it does provide all sorts of data from high temps, to precip chances, to risk of tornadoes.

You can send your request via SOAP, which is the recommended way of doing it. I would recommend using nuSOAP, but you are free to use whatever you like best. There is also a native PHP SOAP library. The NWS also offers the ability to retrieve the information by calling a simple URL with a query string.

Note: You can only query for a forecast by providing the ZIP code or lat/lon pairs, however, the NDFD also provides the ability to query for city names & zip codes and get the lat/lon pairs in return. See this SOAP Response Generator for more information and also the ability to get real responses from the server.

All data is received back in XML format, so you need to have a good grip on parsing XML data.

Source #2: XML Feeds of Current Weather Conditions

Another data feed service provided by the NWS, this product provides current conditions from all NWS weather stations. If the current conditions are desired for only a few weather stations, they can be fetched individually. The option is also available to download all current conditions in one zip file.

All data is, again, received in XML format, so you need to have a good grip on how to process XML data. The zip file contains the XML file for every weather station, so some programming is needed to extract the file and import each and every XML file.

Source #3: Weather.gov/data

This last data source from the national weather service is not well documented, and is very difficult to integrate into any software. If you are looking for those English forecasts that read something like “Monday…Mostly cloudy with a 40 percent chance of light snow. Highs around 30.“, then you need to parse this next data source by hand. We don’t have the luxury of XML here.

Have a look at this link. This is what they call the “Zone Forecast Product” for my local weather station. In order to get the ZFP for your station area, you need to load http://www.weather.gov/data/XXX/ZFPXXX, where XXX is the three-letter code for your station. As you can see, there are several forecasts on that page. That’s because there are many zones in one station area. It’s up to you to find out which one you want.

Source #4: Weather Underground XML API

Our next data feed is from a non-government organization. Their Wiki now says that their data is free of charge for “personal, non-commercial purposes”. If you are using their data for commercial or for-profit sites, be sure to contact them for licensing. If you are not using this data for profit, it’s one of the easiest data sources to use. All you need to know is how to parse XML and fetch remote pages.

You can’t download current conditions or forecasts in bulk, but you can query by zip code, airport code, or city. With using the NWS data you have to use the zip code, lat lon, zone code, or station number.

Wunderground does provide something that the National Weather Service does not. Wunderground has a vast network of personal weather stations and webcams. So if you query for current conditions, you get the NWS station observations as well as live views of the skyline from people’s webcams and data from personal weather stations.

Source #5: Weather.com XML Data Feed

This one is not my favorite because it has the most limitations. You get location specific information, current observations, and two-day forecasts, but there are several limitations:

Must link back to weather.com

Can’t mix weather.com data with data from other sources

Don’t modify the data (makes sense to preserve their reputation)

Can’t redistribute the weather data

Must display a weather.com logo

Developed application must be free to use/access

These are just a few of them, you will have to check out the data source to see your full list of requirements to use the data. Point is, you will have to go through some legal mumbo-jumbo before you can begin coding your application. The up-side with this source is that it is well documented.

So there you have it. I have provided you with enough data to launch your own weather site. It’s up to you to parse and present the data. The point of this post was to show you the vast amount of weather data that is widely available. Watch our RSS feed for future posts, as I will be posting some implementation code on some of these data sources in the future.

If you have something you would like to see sample code for, or if you would like to see something explained in more detail, please let your voice be heard! (post a comment)

No related posts.

5 Responses to “5 Sources of Free Weather Data for your Site”

Thank you for laying out each source, this is great and hepeful. I wish I could download these source included in your sample, for some reason, they are not vailable, is there any other place I can look up?

I find this information really useful. However i am doing a project on how to extract data/ information from a weather station website using PHP . How would you suggest i go about doing this. Any tips would be greatly appreciated

Sort of – I believe only sources 4 & 5 would work for you. Sources 1, 2, & 3 are from the National Weather Service which is a US government entity.

Leave a Reply

Name (required)

Mail (will not be published) (required)

Website

Wordpress doesn't like it when you post PHP code. Go save your code
at pastebin, and post the link here.

Notify me of followup comments via e-mail

Notify me of new posts by email.

About the Author

Andrew has been coding PHP applications since 2006, and has plenty of experience with PHP, MySQL, and Apache. He prefers Ubuntu Linux on his desktop and has plenty of experience at managing CentOS web servers. He is the owner of Wells IT Solutions LLC, and develops PHP applications full time for anyone that needs it as well as does desktop computer support locally in the local area. He spends most of his free time exploring new programming concepts and posting on The Webmaster Forums.