elDiario mapped the heights of every building in Spain for one of year’s most-read articles

By Raúl Sánchez


Madrid, Madrid, Spain


With its innovative and interactive journalistic project, “Spain lives in flats,” elDiario.es analysed the footprint of more than 12 million buildings.

The idea was to map the height of Spanish cities in 3D to analyse their sustainability and impact on the current urban society. The investigation included narrative visualisations and showed Spain is one of the countries with the highest and most dense cities.

Two of every three Spaniards live in flats and apartments and only one-third in single-family and semi-detached houses.

Research showed the difference between population density and the average height of cities.
Research showed the difference between population density and the average height of cities.

This project was born by simply counting floors.

We looked at buildings in our cities and counted the number of floors of each one: eight floors, 10, 13, etc. This was different in other cities we visited, which didn’t have many tall buildings (like suburbs in the United States). Without any formal data, we identified a pattern. Then we started to see if we could prove that with cadastral data.

12 million and counting 

The hardest part of the project was compiling and automating the download of the footprint of more than 12 million buildings and processing that amount of information. We created an R script that downloaded cadastral data of the buildings of more than 7,600 municipalities, one by one.

The total size of the downloaded files exceeded 200GB. While processing the data, the journalists found errors in the data that were later corrected after notifying the cadastral institution.

Then, we processed and joined in R all downloaded files to have a single database with the details of all the buildings in Spain. For example, we verified the data of 12 million buildings, calculated the height of every building from the part that occupies the most built volume in the plans, and extracted the date of the building from the start of construction.

All these processes were repeated several times during the year due to the publication of corrections and allowed us to, for the first time in Spain, have a database and a map with the heights of all the buildings in the country.

This project was the first to compile the cartographic plans of all the buildings currently standing in the Spanish territory in a single database and proved that in Spain we live in tall buildings. We live in flats.

Gathering the right tools

We used R, Rstudio, QGIS and Tippecanoe for data compilation, processing, and analysis. We did a lot of tests to compress the geographic information as much as possible to be able to map it on all devices. D3.js and Javascript were used for data visualisation; Mapbox for mapping the building footprint. HTML, Javascript, and Scrollama were used for scrolling Web pages.

When considering the story’s structure, we conceived it as a journey from the small anecdote to the big phenomenon. For this reason, the piece begins by telling the story of a building in A Coruña and then explaining vertical urbanism in Spain. This story works as a historical journey through each urban model developed in Spain contextualised with graphics and details of each moment.

The story began with telling about a building in A Coruña to explain vertical urbanism.
The story began with telling about a building in A Coruña to explain vertical urbanism.

This project has proved that innovative narratives are useful and welcomed by elDiario.es users. This project was also a bet to publish content in English for the first time due to the importance of giving access to first-time published data to an international audience.

The publication has been viewed by more than 200,000 users, and it was one of the most-read articles of the year in elDiario.es.

It also became one of the articles that encourage people to subscribe and pay to support elDiario.es during the year, according to our statistics. Additionally, the publication doubled the average time of view of a usual article in elDiario.es and shows how people are willing to read stories about complex issues if we make them attractive.

About Raúl Sánchez

By continuing to browse or by clicking “ACCEPT,” you agree to the storing of cookies on your device to enhance your site experience. To learn more about how we use cookies, please see our privacy policy.