Plotting territorial income distribution and other demographic indicators in the city of Barcelona with Python

In this Notebook we explain how to implement Python codes to plot choropleth maps of territorial income distribution and other demographic indicators in the city of Barcelona obtained from Barcelona open data repository using Python's Folium library.

The first dataset that we are going to analyze is the Renta Familiar Disponible (RFD) index dataset, this dataset contains the Disposable Family Income Index by Neighborhood, the most recent one is from year 2017.

https://opendata-ajuntament.barcelona.cat/data/en/dataset/20170706-districtes-barris provides json files with detail of administrative units of the city of Barcelona : districts, neighbourhoods, area of interest, basic statistical areas (AEB) and census areas. Today, Barcelona contains 10 different districts and 73 neighborhoods. In this article we employ neighborhood datas.

According to https://opendata-ajuntament.barcelona.cat/ca/faqs , the coordinates in this json file use Spatial Reference System EPSG 25831, we need to transfom this system into EPSG 4326, which is the more standard reference system that we use nowadays. The simplest way to transform coordinates systems in Python is to use pyproj, i.e. the Python interface to PROJ.4 library.

To better differentiate neigborhoods with above average RFD index with neigborhoods with below average RFD, we can plot again choropleth map with 2 different color scales as illustrated in following codes.

Population map:

Disposable household income in euros per capita in the city of Barcelona

Demographic indicators. Immigration registration rate (‰ inhabitants) of the city of Barcelona. This rate is the relation between registrations due to immigration in one year and the population of the same year per thousand inhabitants. Column 'Nombre' represents the number of Immigration registration per thousand inhabitants. https://opendata-ajuntament.barcelona.cat/data/en/dataset/est-demo-taxa-immigracio

Demographic indicators. Birth rate (‰ inhabitants) of the city of Barcelona available at: https://opendata-ajuntament.barcelona.cat/data/en/dataset/est-demo-taxa-natalitat

Life expecatancy obtained from: https://opendata-ajuntament.barcelona.cat/data/es/dataset/est-sp-esp-vida

List of hospitals and centres of primary health service of the city of Barcelona: https://opendata-ajuntament.barcelona.cat/data/en/dataset/sanitat-hospitals-atencio-primaria