A tool for downloading Spanish COVID-19 and mobility data
Project description
flowmaps-data
A tool for downloading COVID-19 and mobility datasets for Spain.
The database integrates two main types of data:
-
Time dependent population mobility networks across Spain (provided by MITMA and INE)
-
Daily reports of COVID-19 cases in Spain, at different levels of spatial resolution (provided by the CNE and the different Autonomous Communities)
All the data records are associated with a specific area from a geographic layer:
- Geographic layers for Spain, in geojson format, at different levels of spatial resolution.
All the data has been gather from official access points.
More info about the data: https://flowmaps.life.bsc.es/flowboard/data
API: https://flowmaps.life.bsc.es/api
Contact us: https://flowmaps.life.bsc.es/flowboard/contact
Installation
Install using pip:
pip install flowmaps-data
Install manually:
Create virtual environment:
virtualenv env --python=python3
source env/bin/activate
Install python dependencies:
pip3 install -r requirements.txt
Usage
Command line utility
usage: flowmaps-data [-h] COLLECTION [list describe download]
examples:
# Geojson layers
flowmaps-data layers list
flowmaps-data layers describe --layer cnig_provincias --provenance
flowmaps-data layers describe --layer cnig_provincias --plot
flowmaps-data layers download --layer cnig_provincias
# Consolidated COVID-19 data
flowmaps-data covid19 list
flowmaps-data covid19 describe --ev ES.covid_cpro
flowmaps-data covid19 download --ev ES.covid_cpro --output-file out.csv --output-type csv
# Deceased datasets
flowmaps-data deceased list
flowmaps-data deceased describe --ev ES.hosp_covid_cpro
flowmaps-data deceased download --ev ES.hosp_covid_cpro --output-file out.csv --output-type csv
# Population
flowmaps-data population list
flowmaps-data population describe --layer cnig_provincias
flowmaps-data population download --layer zbs_15 --output-file out.csv
# Origin-destination daily mobility (from MITMA)
flowmaps-data daily_mobility_matrix list
flowmaps-data daily_mobility_matrix describe
flowmaps-data daily_mobility_matrix download --source-layer cnig_provincias --target-layer cnig_provincias --start-date 2020-10-10 --end-date 2020-10-16 --output-file out.csv
# Daily zone movements (from MITMA)
flowmaps-data zone_movements list
flowmaps-data zone_movements describe
flowmaps-data zone_movements download --layer cnig_provincias --output-file out.csv --start-date 2020-10-10 --end-date 2020-10-10
# Other datasets
flowmaps-data datasets list
flowmaps-data datasets describe --ev ES.covid_cpro
flowmaps-data datasets download --ev ES.covid_cpro --output-file out.csv --output-type csv
# Mobility Associated Risk
flowmaps-data risk list
flowmaps-data risk list-dates
flowmaps-data risk download --source-layer cnig_provincias --target-layer cnig_provincias --ev ES.covid_cpro --date 2020-10-10 --output-file out.csv --output-format csv
Python module
from flowmaps_data import geolayer, covid19, dataset, daily_mobility_matrix, population, zone_movements
# Geojson layers
geojson = geolayer('cnig_provincias')
# Consolidated COVID-19 data
df = covid19(ev='ES.covid_cpro')
# Raw health datasets
df = dataset(ev='ES.covid_cpro')
# Origin-destination daily mobility (from MITMA)
df = daily_mobility_matrix(source_layer='cnig_provincias', target_layer='cnig_provincias', start_date='2020-11-01', end_date='2020-12-01', source='28', target='08')
# Daily zone movements (from MITMA)
df = zone_movements(layer='cnig_provincias')
# Population
df = population('cnig_provincias')
More examples
Plot daily incidence by province
from flowmaps_data import geolayer, covid19
import plotly.graph_objects as go
# Download geojson layer
geojson = geolayer('cnig_provincias')
# Download COVID-19 data
df = covid19(ev='ES.covid_cpro')
# Select data for one date
date = '2020-10-10'
df = df[df['date'] == date]
# Plot
fig = go.Figure(go.Choroplethmapbox(geojson=geojson,
locations=date_df['id'],
z=date_df['new_cases'],
colorscale="Reds",
marker_opacity=0.8))
fig.update_layout(title=f'Covid-19 daily incidence at {date}',
mapbox_style="carto-positron",
mapbox_zoom=4.5,
mapbox_center={"lat": 40.495178477814555, "lon": -3.717336960173357})
fig.update_layout(margin={"r":0,"t":30,"l":0,"b":0})
fig.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flowmaps_data-0.0.25.tar.gz
.
File metadata
- Download URL: flowmaps_data-0.0.25.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8d5d5239e2bd7bea93d7b326b91097f528130d31ef3b1bc6bb528099d48490 |
|
MD5 | 0db65af3dd29af3c7b7333648d7ea16a |
|
BLAKE2b-256 | 4609585ea3cfcc756ae661735aac57d9b04844c042ccfc32154342a7f66d6e93 |
File details
Details for the file flowmaps_data-0.0.25-py3-none-any.whl
.
File metadata
- Download URL: flowmaps_data-0.0.25-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0650954610005324d578fb507e7df35da463e671e984279e2855ce944c4a7585 |
|
MD5 | 0984ceb580e473207de0a23c882b7344 |
|
BLAKE2b-256 | 0707087c3b523db1bb08b34f6215c58428cad79b5e621aa2ffdf5c74b837f47b |