Current weather status

Ever wondered what the weather is like somewhere on this planet right now? Maybe somewhere where your special other is, or where you want to travel, or just out of data sciencey curiosity. Or maybe you want to study weather patterns and global warming. Of course, it is implied that you do not want to use Google or other more or less accurate readily available services.

Well, you are close to being able to find it all by yourself, and really accurately too. One of the industries that relies massively on accurate weather information is aviation. Almost all airports open for traffic publish weather information every 30 minutes, and sometimes even forecasts the weather for the following few hours, if there are chances of it changing significantly. These reports are called METAR reports.

All you need to do is find a way to access that kind of data. Fortunately, some people have already thought about this and provide weather data in real time. One such service is AVWX, the Aviation Weather REST API.

All you are left with to do is to call the API for a specific airport code (ICAO format), e.g., EGLL for London Heathrow. The example below uses Python and the urllib2 and json libraries to call the service and decode the answer into JSON.

json.load(urllib2.urlopen('http://avwx.rest/api/metar.php?station=EGLL&format=JSON')

Once you reach this point, it is just a matter of parsing the JSON values that are returned.

{"Altimeter": "1016", "Cloud-List": [["BKN", "031"], ["BKN", "046"]], "Dewpoint": "02", "Flight-Rules": "VFR", "Other-List": [], "Raw-Report": "EGLL 191320Z AUTO 22013KT 9999 BKN031 BKN046 10/02 Q1016 NOSIG", "Remarks": "NOSIG", "Remarks-Info": {}, "Runway-Vis-List": [], "Station": "EGLL", "Temperature": "10", "Time": "191320Z", "Units": {"Altimeter": "hPa", "Altitude": "ft", "Temperature": "C", "Visibility": "m", "Wind-Speed": "kt"}, "Visibility": "9999", "Wind-Direction": "220", "Wind-Gust": "", "Wind-Speed": "13", "Wind-Variable-Dir": []}

The raw METAR is included if you want to parse that directly. Additionally, some of the values included in there are explicit, some are just abbreviations used in aviation. A good place to look at if you want to understand what they mean is Texas A&M University, where you can find a quick course on METARs.

There are some Twitter accounts which already publish real-time weather information based on these METAR reports: Vremea la Iași and Vremea la Cluj-Napoca.

Of course, you are limited by the need of having a reporting weather station (usually an airport) wherever you want to look. But it should do the job to start with.

Good weather to all!

Leave a Reply

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