Displaying air pollution data


Last week I was contacted by my friend Marcelo about increasing awareness of air pollution problems in Santiago, this web Chile. He was becoming involved in the problem from a technical point of view (GIS and urban forestry). One of the main problems was the lack of proper information for decision making, look so we decided to quickly put together a prototype. Today the page on particulate material pollution went online.


The general process was relatively simple. CONAMA provides data on pollution in graphical form (see, for sale for example, here). I had a quick look at the pages using Firebug, which showed that all the data used for the graphs was contained in one of the javascript files called by the page (variable.js). Then I could obtain up to date pollution data by reading that file, which seems to be updated hourly.

The other component was the location of the air quality stations together with the coordinates of the polygon that marks the city boundary. Marcelo provided me with a KML file containing all the coordinates.

The really fun part was to write a script using Python glueing all these components. The advantages of working with such a great high level language is the default library, which makes chores like reading a file located in another web site very simple, like:

import urllib
f = urllib.urlopen('http://www.conama.cl/rm/airviro/hoy/variable.js')
lines = f.readlines()

Probably the most challenging part has been to quickly learn the basics of KML (without having much free time to do so). The documentation for KML is OK, but the tutorial was not exactly what I was trying to do, so there was a fair amount of trial and error to get things working properly.

Overall, coming back to Python (which I started using in version 1.5) has been a lot of fun, particularly when one has a project of ’social value’.

Filed in chile, environment, geocoded, programming

No comments yet.

Write a comment: