https://github.com/urbananalyst/paris-bikes
https://github.com/urbananalyst/paris-bikes
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/urbananalyst/paris-bikes
- Owner: UrbanAnalyst
- Created: 2022-09-08T19:05:39.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-09T15:42:31.000Z (almost 4 years ago)
- Last Synced: 2025-02-14T02:19:21.980Z (over 1 year ago)
- Language: R
- Homepage: https://UrbanAnalyst.github.io/paris-bikes
- Size: 11 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
[](https://github.com/UrbanAnalyst/paris-bikes/actions?query=workflow%3AR-CMD-check)
[](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 <- "////"
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 ("///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)
```