Mobility patterns play a critical role in a wide range of societal challenges, from epidemic modeling and emergency response to transportation planning and regional development. Yet, access to high-quality, timely, and openly available mobility data remains limited. In response, the Spanish Ministry of Transportation and Sustainable Mobility has released daily mobility datasets based on anonymized mobile phone data, covering districts, municipalities, and greater urban areas from February 2020 to June 2021 (version 1) and again from January 2022 onward (version 2). pySpainMobility is a Python package that simplifies access to these datasets and their associated spatial tessellations through a standardized, well-documented interface. By lowering the technical barrier to working with large-scale mobility data, the package enables reproducible analysis and supports applications across research, policy, and operational domains.
The full documentation of the library is available on the pySpainMobility website and a paper with some examples and further details is available on arXiv. If you are using the library or it content, please use this reference:
Beneduce, C., Gullón Muñoz-Repiso, T., Lepri, B., & Luca, M. (2025). pySpainMobility: a Python Package to Access and Manage Spanish Open Mobility Data
Bibtex:
@misc{beneduce2025pyspainmobility,
title={pySpainMobility: a Python Package to Access and Manage Spanish Open Mobility Data},
author={Ciro Beneduce and Tania Gullón Muñoz-Repiso and Bruno Lepri and Massimiliano Luca},
year={2025},
eprint={2506.13385},
archivePrefix={arXiv},
primaryClass={cs.CY},
url={https://arxiv.org/abs/2506.13385},
}
The documentation of pySpainMobility classes and functions is available at pyspainmobility.github.io/pySpainMobility
scikit-mobility for Python >= 3.8 and all it's dependencies are available from conda-forge and can be installed using
conda install -c conda-forge scikit-mobility.
Note that it is NOT recommended to install scikit-mobility from PyPI! If you're on Windows or Mac, many GeoPandas / scikit-mobility dependencies cannot be pip installed (for details see the corresponding notes in the GeoPandas documentation).
-
Create an environment
venvpython3 -m venv venv -
Activate the environment
source venv/bin/activate -
Install
pySpainMobilitypip install pyspainmobility
-
Create an environment
mobilityand install pipconda create -n mobility pip python=3.9 -
Activate
conda activate mobility -
Install
pySpainMobilityconda install -c pyspainmobility pyspainmobility
Examples can be found in the repository named Examples
If you prefer R, check out the spanishoddata package by Egor Kotov et al.
