Description Usage Arguments Details See Also Examples
R interface to the CycleStreets.net journey planning API, a route planner made by cyclists for cyclists. See cyclestreets.net/api for details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | journey(
from,
to,
plan = "fastest",
silent = TRUE,
pat = NULL,
base_url = "https://www.cyclestreets.net",
reporterrors = TRUE,
save_raw = "FALSE",
cols = c("name", "distances", "time", "busynance", "elevations", "start_longitude",
"start_latitude", "finish_longitude", "finish_latitude"),
cols_extra = c("crow_fly_distance", "event", "whence", "speed", "itinerary",
"clientRouteId", "plan", "note", "length", "quietness", "west", "south", "east",
"north", "leaving", "arriving", "grammesCO2saved", "calories", "edition",
"gradient_segment", "elevation_change", "provisionName"),
smooth_gradient = TRUE,
distance_cutoff = 50,
gradient_cutoff = 0.1,
n = 3
)
|
from |
Longitude/Latitude pair, e.g. |
to |
Longitude/Latitude pair, e.g. |
plan |
Text strong of either "fastest" (default), "quietest" or "balanced" |
silent |
Logical (default is FALSE). TRUE hides request sent. |
pat |
The API key used. By default this uses |
base_url |
The base url from which to construct API requests (with default set to main server) |
reporterrors |
Boolean value (TRUE/FALSE) indicating if cyclestreets (TRUE by default). should report errors (FALSE by default). |
save_raw |
Boolean value which returns raw list from the json if TRUE (FALSE by default). |
cols |
Columns to be included in the result, a character vector or |
cols_extra |
Additional columns to be added providing summaries of gradient and other variables |
smooth_gradient |
Identify and fix anomalous gradients? TRUE by default. See https://github.com/Robinlovelace/cyclestreets/issues/14 |
distance_cutoff |
Distance (m) used to identify anomalous gradients |
gradient_cutoff |
Gradient (%, e.g. 0.1 being 10%) used to identify anomalous gradients |
n |
The number of segments to use to smooth anomalous gradents. The default is 3, meaning segments directly before, after and including the offending segment. |
Requires the internet and a CycleStreets.net API key. CycleStreets.net does not yet work worldwide.
You need to have an api key for this code to run.
By default it uses the CYCLESTREETS environment variable.
This can be set with usethis::edit_r_environ()
.
A full list of variables (cols
) available is represented by:
1 2 3 4 5 6 7 | c("time", "busynance", "signalledJunctions", "signalledCrossings",
"name", "walk", "elevations", "distances", "start", "finish",
"startSpeed", "start_longitude", "start_latitude", "finish_longitude",
"finish_latitude", "crow_fly_distance", "event", "whence", "speed",
"itinerary", "clientRouteId", "plan", "note", "length", "quietness",
"west", "south", "east", "north", "leaving", "arriving", "grammesCO2saved",
"calories", "edition", "geometry")
|
See www.cyclestreets.net/help/journey/howitworks/ for details on how these are calculated.
json2sf_cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
from = c(-1.55, 53.80) # geo_code("leeds")
to = c(-1.76, 53.80) # geo_code("bradford uk")
r1 = journey(from, to)
names(r1)
r1[1:2, ]
r1$grammesCO2saved
r1$calories
plot(r1[1:4])
plot(r1[10:ncol(r1)])
to = c(-2, 53.5) # towards Manchester
r1 = journey(from, to)
names(r1)
r2 = journey(from, to, plan = "balanced")
plot(r1["quietness"], reset = FALSE)
plot(r2["quietness"], add = TRUE)
r3 = journey(from, to, silent = FALSE)
r4 = journey(from, to, save_raw = TRUE)
r5 = journey(c(-1.524, 53.819), c(-1.556, 53.806))
plot(r5["gradient_segment"])
plot(r5["gradient_smooth"])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.