Learn R Programming

hereR (version 0.4.0)

intermodal_route: HERE Intermodal Routing API: Calculate Route

Description

Calculates route geometries (LINESTRING) between given pairs of points using the HERE 'Intermodal Routing' API.

Usage

intermodal_route(
  origin,
  destination,
  datetime = Sys.time(),
  results = 3,
  transfers = -1,
  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 (default = Sys.time()).

results

numeric, maximum number of suggested route alternatives (Valid range: 1 and 7, default = 3).

transfers

numeric, maximum number of transfers allowed per route (Valid range: -1 and 6, default = -1).

url_only

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

Value

An sf object containing the requested intermodal routes.

References

HERE Intermodal Routing API: Routes

Examples

Run this code
# NOT RUN {
# Provide an API Key for a HERE project
set_key("<YOUR API KEY>")

# Change POIs to Berlin, as service is not available in Switzerland
library(sf)
poi <- data.frame(
 name = c("HERE Berlin", "Treptow", "Potsdam", "Tiergarten"),
 lng = c(13.384944, 13.461215, 13.058351, 13.336490),
 lat = c(52.531056, 52.493908, 52.403587, 52.514557)
) %>%
 st_as_sf(coords = c("lng", "lat")) %>%
 st_set_crs(4326)

# Intermodal routing
routes <- intermodal_route(
  origin = poi[1:2, ],
  destination = poi[3:4, ],
  url_only = TRUE
)
# }

Run the code above in your browser using DataLab