Ivann Schlosser
This repo contains the code of a clustering algorithm for urban analytics, specifically to identify neighbourhoods in a city. It was developed and tested in London with GPS mobility data of a sample of residents coming from an industry partner, Locomizer Ltd. and open source data from OSM.
You will need a C/C++ compiler, which comes with the developer tools of
R. It has a few dependencies and calls python from within R
with the
reticulate
package.
The workflow relies on the osmium library, please install it separately. If using mac, you can install it from homebrew by running:
brew install libosmium
This project uses
renv
to setup an
R and python environments. Once the repo is cloned, open it and start
the environment with the following command:
renv::activate()
This should download all the R and python packages required to run this algorithm.
There are multiple ways to start working with this repository, the easiest being to analyze a city from the predefined set. It will still require downloading the corresponding OSM file from geofabrick.
The necessary OSM file will be either the country or region containing the city. For reusability reasons, it might be better to download the whole country. Say if you are running the analysis on several cities across France, itβs easier to get a single osm file for the country, than each region individually.
The OSM files, should be put in the data/osm_extracts/
folder. For
example, if working on France, the OSM extract will be looked for at the
following location in the directory:
data/osm_extracts/australia-latest.osm.pbf
Currently, a set of cities are supported, this essentially means that
their bbox and associated .pbf
files are located. A new city can be
added manually quite easily, this will be covered in another section.
To visualise the available cities, run
names(rlist::list.load("cities.rds"))
. Select the one yyou want, it is
recommended to start with a smaller one to see that everything works
initially.
Open the params.R
script and in the first line of code assign to the
city
variable whichever city you chose. Default is aix-en-provence
.
You can now run a simulation by calling the divbscan_ny.R
once the raw
osm extract is at the right location and you have entered a city name in
the parameters.
Run for example in your R console :
source("divbscan_ny.R")
Future updates of this repository will aim to automate as much as possible the setup step.