The Ministry for Housing, Communities and Local Government (MHLCG, previously DLUHC) has run a data innovation project developing data prototypes using mobility data from O2 Motion. The data product from O2 Motion we use is anonymised and aggregated origin-destination journey counts at MSOA level.
The main branch is protected, and all of the code which sits in main has been reviewed by the project team. We're working on a series of prototypes and experimental analyses using this data. The development work is in separate branches, and merged into main when reviewed.
Most of our prototypes are stored in analysis/
, with some in notebooks/
.
We have common code and function in src/
Our code points to MHCLG's storage, but quite a lot of the data is publicly available. Here's a non-exhaustive list of data sources:
ONS public transport isochrones
Population weighted centroids for MSOAs
We use the Ordnance Survey API for basemaps
analysis/Local_travel_areas/
For communities (MSOAs) or towns (BUAs), we find the area containing X% (default 90%) of destinations for trips originating from our origin. This gives the area in which people spend the majority of their day-to-day life.
analysis/Local_travel_areas/
For towns and cities, we find the most important larger settlements, based on travel patterns. This give wider context about the economic circumstances for towns, and their interdependecnes.
analysis/FEAs/
We use network graph analysis to group MSOAs into relatively self-contained economic communities.
analysis/adhoc/ldc_towns_analysis/
For towns we construct summary metrics to contribute to town data packs. MHCLG has published these data packs: https://www.gov.uk/government/publications/long-term-plan-for-towns-data-packs-for-55-towns
analysis/Local_travel_areas/
For a given destination, either a BUA or MSOA, we find the region where the majority of travel originated from. This gives us a measure of the catchment area of effect for local changes.
/notebooks/seasonality
We look at the variation of trips to destinations through the year and identify local areas with highly seasonal travel patterns.
/analysis/isochrone_exceedance/
The ONS have published spatial data on the areas which can be reached within 15, 30, 45, and 60 minutes via walking and public transport. We compare these to observed travel patterns.
/analysis/unexpectedness/
We have developed a prototype for training a neural network algorithm on national travel patterns to then compare local areas and find the journeys which are most over- or under-observed.
/analysis/eigenvectors/
To investigate functional economic areas, we experimented with casting the origin-destination data as a square matrix and mapping the dominant eigenvectors.
/analysis/Commuterflows/
Tests of comparing commuter flow methods with the O2 data.
/analysis/adhoc/find_city_centres
A quick prototype of using population movement data to define where the centre of cities is located.
The project is primarily written in python. We have a shared environment - environment.yml
The terminal command to build a new environment with conda is:
conda env create -f environment.yml
For reference, the command to use an existing environment (called mobility) is:
conda activate mobility
If you add new python packages during a prototype, include them in the PR for that branch.
To re-write out the environment, use:
conda env export > environment.yml
When an environment YAML has been updated, to update an existing environment, use:
conda env update --name mobility --file environment.yml --prune
For MHCLG users, the data is hosted internally on the Consolidated Data Store. If the SQL queries give errors when running, this is probably caused by permissions for the data table on the CDS - check with the project team on this.