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 'public transport', incorporating current traffic information, if available. For routes using the transport mode "car" a vehicle type can be specified, to obtain an estimate of the consumption.

route(
  origin,
  destination,
  datetime = Sys.time(),
  arrival = FALSE,
  type = "fastest",
  mode = "car",
  traffic = FALSE,
  vehicle_type = "diesel,5.5",
  url_only = FALSE
)

Arguments

origin

sf object, the origin locations of geometry type POINT.

destination

sf object, the destination locations of geometry type POINT.

datetime

POSIXct object, datetime for the departure (or arrival if arrival = TRUE).

arrival

boolean, calculate routes for arrival at the defined time (default = FALSE)?

type

character, set the routing type: "fastest", "shortest" or "balanced".

mode

character, set the transport mode: "car", "pedestrian", "carHOV", "publicTransport", "truck" or "bicycle".

traffic

boolean, use real-time traffic or prediction in routing (default = FALSE)? If no datetime is set, the current timestamp at the moment of the request is used for datetime.

vehicle_type

character, specify the motor type of the vehicle: "diesel", "gasoline" or "electric". And set the consumption per 100km im liters (default = "diesel,5.5").

url_only

boolean, only return the generated URLs (default = FALSE)?

Value

An sf object containing the requested routes.

Note

The public transport routes (mode = "publicTransport") provided by route are not considering the time tables of the public transport providers. Use connection for public transport routes that consider time tables.

References

HERE Routing API: Calculate Route

Examples

# 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, mode = "car", type = "fastest", traffic = TRUE, vehicle_type = "diesel,5.5", url_only = TRUE )