2020-05-13 22:00

Barcelona Air Quality - The Lockdown impact

Disclaimer: I am not a expert in this subject, nor should you take any specific conclusions from these results, I've done the best to base this on accurate data, but it's quite a varied and complicated topic.

As a resident of the beautiful city of Barcelona, one thing that has struck me living here is the unfortunate amount of pollution that can be present in the city, this became even more noticable as the state of alarm was issued for the Covid19 pandemic and the city came to a standstill and coincidently the air seemed to get better additionally noticably in photos of the city which seemed less hazy, this has also been shown in other cities across the world.

I discovered that Barcelona has a wide range of Open Data available for reuse at which also includes air quality measurements from sensors within the city.

With this data I decided to see what the effect of the lockdown was and to see if there was any noticable change in the data.

Defining Air Quality

The concentration of an air pollutant (eg. ozone) is given in micrograms (one-millionth of a gram) per cubic meter air or µg/m3. (1)

To determine the value of the numbers an air quality index is used, I've summarised and simplified Air quality index (2) for the purposes of this article, but a slightly more detailed one can be seen on the legend here:


In general NO2 and PM10 are two of the most common used measurements for health impact of air pollution and are largely sourced from vehicle emissions hence significant in this data from Barcelona. (3) There is also NOx which is a generic term for the nitrogen oxides that are most relevant for air pollution.

The WHO also has a general fact sheet about pollutents

You can also view Spain's overall pollution index (4) for comparison of other measures.

Data used

The air quality data sets were taken from - These were CSV files and then parsed with a script into a more useful format.

The data is from various monitoring stations across Barcelona, I took this data and averaged out over the day to get daily averages for the various pollutants.

Note: For some of the dates during April 2020 there was some missing data for period 15/4 to 30/4 however only from one monitoring station, I don't feel this affects the findings as we are using overall averages.

Graphing the data

Using Python, pandas and pygal I created a script to process the data and build charts available on github

Graphing this year

This graph was averaged over weeks from January 2020 to End of April 2020, the lockdown came into effect on March 15th and you can noticable see a dramatic decline in all the pollutants.

Comparing April 2020 to April 2019

These show as seperate graphs the comparisons of April 2020 to the previous year of April 2019 for NO2 and PM10.




As per my disclaimer, I'm not an expert on this subject and there are nuances, I just find it interesting to see how the dramatic change in our lives can have a quite noticable knock on effect.