Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyclestreets/cyclestreets-r
An R interface to cyclestreets.net APIs
https://github.com/cyclestreets/cyclestreets-r
cycling r routing transport transportation-planning
Last synced: 3 days ago
JSON representation
An R interface to cyclestreets.net APIs
- Host: GitHub
- URL: https://github.com/cyclestreets/cyclestreets-r
- Owner: cyclestreets
- License: gpl-3.0
- Created: 2018-04-27T05:38:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-04T12:07:43.000Z (about 1 month ago)
- Last Synced: 2024-12-19T05:57:50.110Z (24 days ago)
- Topics: cycling, r, routing, transport, transportation-planning
- Language: R
- Homepage: https://rpackage.cyclestreets.net/
- Size: 3.92 MB
- Stars: 27
- Watchers: 5
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
- open-sustainable-technology - cyclestreets - The goal of cyclestreets is to provide a simple R interface to the CycleStreets routing service. (Consumption / Mobility and Transportation)
- jimsghstars - cyclestreets/cyclestreets-r - An R interface to cyclestreets.net APIs (R)
README
---
output: github_document
---[![R-CMD-check](https://github.com/cyclestreets/cyclestreets-r/workflows/R-CMD-check/badge.svg)](https://github.com/cyclestreets/cyclestreets-r/actions) [![CRAN status](https://www.r-pkg.org/badges/version/cyclestreets)](https://CRAN.R-project.org/package=cyclestreets)
[![R-CMD-check](https://github.com/cyclestreets/cyclestreets-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/cyclestreets/cyclestreets-r/actions/workflows/R-CMD-check.yaml)```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# cyclestreets
The goal of cyclestreets is to provide a simple R interface to the CycleStreets routing service.
It was split-out from **stplanr** for modularity.
## Installation
You can install the released version of cyclestreets from [CRAN](https://CRAN.R-project.org) with:
```{r install, eval=FALSE}
install.packages("cyclestreets")
```Install the development version with **devtools** as follows:
```{r installdev, eval=FALSE}
# install.packages("devtools")
devtools::install_github("cyclestreets/cyclestreets-r")
```## Example
A common need is to get from A to B:
```{r example}
library ("cyclestreets")
# stplanr::geo_code ("leeds rail station")
from = c(-1.544, 53.794)
# stplanr::geo_code ("leeds university")
to = c(-1.551, 53.807)
r = cyclestreets::journey(from, to, "balanced")
sf:::plot.sf(r)
```To get a key go to
Save the key as an environment varible using `export CYCLESTREETS=your_key_here` by adding `CYCLESTREETS=your_key_here` as a new line in your `.Renviron` file, e.g. with the following command:
```{r, eval=FALSE}
usethis::edit_r_environ()
```Check the map is good with leaflet:
```{r, eval=FALSE}
library(leaflet)
p = colorNumeric("RdYlBu", domain = r$quietness, reverse = TRUE)
leaflet(r) %>%
addTiles() %>%
addPolylines(color = ~p(quietness), weight = 20, opacity = 0.9) %>%
addLegend(pal = p, values = ~quietness)
```Or **tmap**, highlighting the recently added 'quietness' variable:
```{r, eval=FALSE}
library(tmap)
tmap_mode("view")
tm_shape(r) + tm_lines("quietness", palette = "RdYlBu", lwd = 3)
``````{r, echo=FALSE}
library(tmap)
tmap_mode("view")
m = tm_shape(r) + tm_lines("quietness", palette = "RdYlBu", lwd = 3)
tmap_save(m, "m.html")
webshot2::webshot("m.html")
```See an interactive version of this map, showing all variables per segment, [here](https://rpubs.com/RobinLovelace/784236).
Or **mapview**:
```{r, eval=FALSE}
mapview::mapview(r)
```Route types available are: fastest, quietest, balanced.
See help pages such as `?journey` and for details.You can also get streets by LTN status.
```{r}
network_ltns = ltns(r)
plot(network_ltns)
```