vl_isochrone | R Documentation |
Build and send a Valhalla API query to get isochrones or
isodistances from a point.
This function interfaces with the Isochrone & Isodistance service.
Note that you must provide either 'times' or 'distances' to compute the isochrones
at given times or distances from the center point.
vl_isochrone(
loc,
times,
distances,
costing = "auto",
costing_options = list(),
server = getOption("valh.server")
)
loc |
one point from which to compute isochrones.
|
times |
vector of travel times (in minutes) to compute the isochrones. The maximum number of isochrones is 4. The minimal value must be greater than 0. |
distances |
vector of travel distances (in kilometers) to compute the isochrones. The maximum number of isochrones is 4. The minimal value must be greater than 0. |
costing |
costing model to use. |
costing_options |
list of options to use with the costing model (see https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#costing-options for more details about the options available for each costing model). |
server |
URL of the Valhalla server. |
An sf MULTIPOLYGON object is returned with the following fields: 'metric' (the metric used, either 'time' or 'distance') and 'contour' (the value of the metric).
## Not run:
# Inputs are data frames
apotheke.df <- read.csv(system.file("csv/apotheke.csv", package = "valh"))
# Extract the first point and compute isochrones at 3, 6, 9 and 12 kilometers,
# using the "auto" costing model
pt1 <- apotheke.df[1, c("lon", "lat")]
iso1 <- vl_isochrone(loc = pt1, distances = c(3, 6, 9, 12), costing = "auto")
# Inputs are sf points
library(sf)
apotheke.sf <- st_read(system.file("gpkg/apotheke.gpkg", package = "valh"),
quiet = TRUE
)
# Extract the first point and compute isochrones at 15, 30, 45 and 60 minutes
# using the "bicycle" costing model
pt2 <- apotheke.sf[1, ]
iso2 <- vl_isochrone(loc = pt2, times = c(15, 30, 45, 60), costing = "bicycle")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.