-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
71 lines (55 loc) · 2.53 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!-- README.md is generated from README.Rmd. Please edit that file -->
[![R build
status](https://github.com/UrbanAnalyst/paris-bikes/workflows/R-CMD-check/badge.svg)](https://github.com/UrbanAnalyst/paris-bikes/actions?query=workflow%3AR-CMD-check)
[![Project Status: Concept](https://www.repostatus.org/badges/latest/concept.svg)](https://www.repostatus.org/#concept)
Tool to estimate bicycle flows throughout the network of metropolitan Paris, France.
## How?
Start by installing and loading the package:
```{r load, eval = FALSE}
remotes::install_github ("UrbanAnalyst/paris-bikes")
library (parisbikes)
```
Then just two steps. First, get the street network of Paris (or anywhere) from Open Street Map.
```{r get-network, eval = FALSE}
path <- "<local>/<directory>/<for>/<paris>/<data>"
pb_get_network (location = "Paris France", path)
```
That function will create a file called "paris-sc.Rds" in the location
specified by "path". Then load the resultant network and use that to calculate
centrality:
```{r centrality, eval = FALSE}
dat <- readRDS ("/<path>/<to>/paris-sc.Rds")
network <- pb_centrality (dat, mode = "bicycle")
```
It is also possible to calculate centrality including the effects of elevation
changes, by specifying an additional "elev_file" parameter as the path to a
local 'geotiff' elevation file. See the function documentation of
`pb_centrality` for details.
## Visualising the results
The following code can be used to visualise the resultant network centrality,
using [the `mapdeck` package](https://symbolixau.github.io/mapdeck/index.html)
(which first requires an API token, as explained in the documentation). The
following code rescales the centrality measures using a value of 3.71 derived
elsewhere to optimally match observed distributions of cycling densities in
Paris.
```{r viz, eval = FALSE}
index <- which (network$centrality > 0)
network <- dodgr::merge_directed_graph (network [index, ])
network$flow <- network$centrality / max (network$centrality)
network$flow <- network$flow ^ (1 / 3.71)
network$width <- 5 * network$flow
```
The following lines will then open an interactive visualization of the flow
densities throughout Paris.
```{r mapdeck, eval = FALSE}
library (mapdeck)
mapdeck (style = mapdeck_style ()) %>%
add_line (net,
origin = c (".vx0_x", ".vx0_y"),
destination = c (".vx1_x", ".vx1_y"),
stroke_colour = "flow",
stroke_width = "width",
stroke_opacity = "flow",
palette = "matlab_like2",
legend = TRUE)
```