Calculates route geometries (LINESTRING
) between given pairs of points using the HERE 'Routing' API.
Routes can be created for various transport modes, as for example 'car' or 'bicycle',
incorporating current traffic information, if available.
For routes using the transport mode "car"
a vehicle consumption model can be specified,
to obtain an estimate of the consumption.
route( origin, destination, datetime = Sys.time(), arrival = FALSE, results = 1, routing_mode = "fast", transport_mode = "car", traffic = TRUE, consumption_model = NULL, url_only = FALSE, type, mode )
origin |
|
---|---|
destination |
|
datetime |
|
arrival | boolean, calculate routes for arrival at the defined time ( |
results | numeric, maximum number of suggested routes (Valid range: 1 and 7). |
routing_mode | character, set the routing type: |
transport_mode | character, set the transport mode: |
traffic | boolean, use real-time traffic or prediction in routing ( |
consumption_model | character, specify the consumption model of the vehicle, see consumption model for more information ( |
url_only | boolean, only return the generated URLs ( |
type | character, 'type' is deprecated, use 'routing_mode' instead. |
mode | character, 'mode' is deprecated, use 'transport_mode' instead. |
An sf
object containing the requested routes.
HERE Routing API: Calculate Route
# Provide an API Key for a HERE project set_key("<YOUR API KEY>") # Get all from - to combinations from POIs to <- poi[rep(seq_len(nrow(poi)), nrow(poi)), ] from <- poi[rep(seq_len(nrow(poi)), each = nrow(poi)),] idx <- apply(to != from, any, MARGIN = 1) to <- to[idx, ] from <- from[idx, ] # Routing routes <- route( origin = from, destination = to, results = 3, transport_mode = "car", url_only = TRUE )