Go straight to the web form.

If you want to know how to design your building you to need to know what the local weather is like. If you want to understand how your building is performing you need to know what weather it was coping with. If you want to install renewable energy – solar panels, wind turbines – you need to know what kind of weather conditions you’ll be able to harness. Weather Underground is a great source of free weather data, aggregating a multitude of independent weather stations all around the world.

I first needed to pull some data from Weather Underground after I found out that the weather station on a university campus down in Cornwall where I’m monitoring a building had been damaged during the construction of another building on the campus. And then I found out the same thing had happened to another building I’m monitoring down there. The problem was I needed months and months of data for two sites, but Weather Underground only seemed to serve up one day at a time. And so was born wunderscraper.py.

You can do some pretty cool things with weather data. This one plots temperature against heating energy use.

Temperature trace

And this one plots the wind conditions for a location. Very useful if you’re considering installing a wind turbine. If you or someone you know are interested, Small-Scale Wind Power: A Practical Guide would make a great present – and it’s on offer this Christmas!

Wind data

After that as a bit of a challenge to improve my non-VBA coding, I thought it might be a nice idea to try and put together a proper web-based API to simplify things a bit [1]. If it gets too much traffic I’ll have to take it down, hobble it, or password protect it – so be gentle!. I don’t want to take real business away from the Wunderground people, but I don’t think there’ll be enough traffic to this site to really worry them.

So, how does it work?

It’s really a very simple API. There are three URL parameters, stationID, startdate and enddate. Basically you build your URL as follows:


Give it a try.

That downloads you a CSV file containing all the data between the two dates specified. For this example the file will be called ICORNWAL14_2012-10-09_2012-10-10.

Since my site is currently hosted in the United States (if you’re looking for hosting, check out my affiliate link [2]), the resulting file comes back with temperatures in Farenheit, rainfall in inches, wind speeds in miles per hour, etc. by default. I’ll add a parameter to specify whether you want imperial/US or metric data in the future but this will do for now. For metric data just tick the checkbox option.

As well as the API, I’ve also put together a web form that you can use to do the downloading if you’re not minded to use the API directly. It’s as easy as putting in the weather station ID which you can find from here, and the start and end date of the period you want.


[1] I know, I know. They have a proper API. But in the words of a blog post I just read, “I don’t need no stinking API”, and I enjoyed the learning process.

[2] Disclosure: Apparently iPage will pay me for referrals, but I’d recommend them anyway. My partner’s site, Another Voice Translations is also hosted through iPage on my recommendation and that was before I knew about the affiliate programme. They made making the transition from a WordPress blog to a self-hosted site really very simple, and adding the scripting that powers this API was also pretty easy. This site is independently owned and the opinions expressed here are my own.

Jamie Bull | jamiebull1@gmail.com

Related Posts

WiGLE is a popular platform which can be used for finding the location of a device using the names of WiFi networks in its vicinity. I’ve written about this before, and wrote some Python code to interact with their API. This API has since been retired and replaced with a new one, as of December […]

Just a quick post to point out a couple of really useful tools. The first is a web-based tool for finding weather files for a location of interest. It’s similar to the Excel EPW finder tool we created a few years back, but much more modern looking. It is however missing a few of the […]

Eppy is a really useful library which I’ve written about several times, since before I really had anything to offer in terms of contributing code. Over the past year or so though, I’ve started to contribute back some of the changes and additions I’ve made while using eppy on academic and commercial projects. This post […]

Leave a Reply

Your email address will not be published. Required fields are marked *