Learn R Programming

hereR (version 0.2.1)

route: HERE Routing API: Route

Description

Calculates route geometries (LINESTRING) between given pairs of points using the '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.

Usage

route(start, destination, type = "fastest", mode = "car",
  traffic = FALSE, vehicle_type = "diesel,5.5", departure = NULL,
  arrival = NULL, url_only = FALSE)

Arguments

start

sf object, Points of Interest (POIs) of geometry type POINT for the start locations.

destination

sf object, Points of Interest (POIs) of geometry type POINT for the destination locations.

type

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

mode

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

traffic

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

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").

departure

datetime, timestamp of type POSIXct, POSIXt for the departure.

arrival

datetime, timestamp of type POSIXct, POSIXt for the arrival. Only specify a departure or an arrival.

url_only

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

Value

An sf object containing the requested routes.

References

HERE Routing API: Calculate Route

Examples

Run this code
# NOT RUN {
# Authentication
set_auth(
  app_id = "<YOUR APP ID>",
  app_code = "<YOUR APP CODE>"
)

# Get all from - to combinations from POIs
library(sf)
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(
  start = from, destination = to,
  mode = "car", type = "fastest", traffic = TRUE,
  vehicle_type = "diesel,5.5",
  url_only = TRUE
)
# }

Run the code above in your browser using DataLab