Basic Health Areas in Madrid
Now being used to impose restrictions due to Covid19 on people's movement and activities.
Since Monday, 21 September 2020 basic health zones have been used in Madrid to impose restrictions on the population in the fight against Covid19. This came as a surprise to the local population - they knew the name of their zone from the name of their health centre but had no idea about what area is served by the health centre.
In this series of block posts I would like to explore the public data on the second wave of Covid19 infections in Madrid using Jupyter notebooks that run on Google Colab and non-proprietory software. You too can access the data, run these notebooks and explore the data yourself.
If you are interested graphical analysis of the Covid19 crisis, I recommend the work of Kiko Llaneras and the team at El País.
This introductory notebook locates polygon data for these basic health zones and the detailed maps showing the area each zone serves.
Libraries to install and import:
!pip install geopandas
!apt-get install poppler-utils
!pip install pdf2image
import geopandas
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from pdf2image import convert_from_path, convert_from_bytes
from pdf2image.exceptions import (PDFInfoNotInstalledError,PDFPageCountError,PDFSyntaxError)
from PIL import Image
df=geopandas.read_file('./maps/zonas_basicas_salud.shp')
df.head()
df.info()
plt.hist(df.pob_pad19)
plt.title('Distribution of population by areas')
plt.ylabel('Number of areas')
plt.box(False)
plt.xlabel('Population');
df.describe()
df[df.pob_pad19==df.pob_pad19.min()]
df[df.pob_pad19==df.pob_pad19.max()]
There are 286 basic health zones, with an average population of around 23_000 people: the Rascafría area has only 2_636 people; the Mar Báltico area has 63_789 people.
df["area_sq_km"] = df['geometry'].area/1_000_000
df['pob_densidad_sq_km'] = df.pob_pad19/df.area_sq_km
df.head()
fig, (ax1, ax2) = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(12,6))
df.plot(ax=ax1, column=df.pob_pad19, cmap='Reds', legend=True)
df.plot(ax=ax1, color='white', edgecolor='grey', alpha=0.1)
ax1.set_title('Total population\n by basic health area')
ax1.axis('off')
df.plot(ax=ax2, column=df.pob_densidad_sq_km, cmap='Reds', legend=True)
df.plot(ax=ax2, color='white', edgecolor='grey', alpha=0.1)
ax2.set_title('Population density\n by basic health area')
ax2.axis('off');
df[df.pob_densidad_sq_km==df.pob_densidad_sq_km.min()]
df[df.pob_densidad_sq_km==df.pob_densidad_sq_km.max()]
print(f'The Madrid region has an area of {int(df.area.sum()/1000000)} sq km, a population of {df.pob_pad19.sum()} \
and a population density of {int(1000000*df.pob_pad19.sum()/df.area.sum())} people per sq km.')
Rascafría has a population density of only 10 people per sq km; Martín de Vargas has a population of 56_446 people per sq km.
Detailed maps are provided for each zone
- List of zones:
Mapas de Zonas Básicas de Salud del Área Única de la Comunidad de Madrid
https://www.madrid.org/iestadis/fijas/estructu/general/territorio/estructucartemzbs.htm
- Individual maps:
https://www.madrid.org/iestadis/fijas/estructu/general/territorio/descarga/zbs13_mar_baltico.pdf
(maps have been downloaded and stored in ./maps/...
)
Conversion of maps from .pdf to .jpg:
convert_from_path('./maps/zbs13_mar_baltico.pdf')[0].resize((1414,1000)).save('./maps/159_mar_baltico.jpg')
convert_from_path('./maps/zbs13_rascafria.pdf')[0].resize((1414,1000)).save('./maps/222_rascafria.jpg')
convert_from_path('./maps/zbs13_martin_de_vargas.pdf')[0].resize((1414,1000)).save('./maps/161_martin_de_vargas.jpg')
Image.open('./maps/222_rascafria.jpg')
Image.open('./maps/159_mar_baltico.jpg')
Image.open('./maps/161_martin_de_vargas.jpg')