Route public transport connections with geometries (LINESTRING) between pairs of points using the HERE 'Public Transit' API. Two modes are provided:

  • summary = FALSE: The public transport connections are returned as mulitple sections with the same vehicle and transport mode. Each section has a detailed route geometry.

  • summary = TRUE: A summary of the connections is retrieved, where each connection is represented as one row with a unified and simplified geometry.

connection(
  origin,
  destination,
  datetime = Sys.time(),
  arrival = FALSE,
  results = 3,
  transfers = -1,
  transport_mode = NULL,
  summary = FALSE,
  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 connections for arrival at the defined time (default = FALSE)?

results

numeric, maximum number of suggested public transport routes (Valid range: 1 and 6).

transfers

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

transport_mode

character, enable or disable ("-" prefix) transport modes. Note: Do not enable and disable modes at the same time (default = NULL).

summary

boolean, return a summary of the public transport connections instead of the sections of the routes (default = FALSE)?

url_only

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

Value

An sf object containing the requested routes.

Examples

# Provide an API Key for a HERE project
set_key("<YOUR API KEY>")

# Connection sections
sections <- connection(
  origin = poi[3:4, ], destination = poi[5:6, ],
  summary = FALSE, url_only = TRUE
)

# Connection summary
summary <- connection(
  origin = poi[3:4, ], destination = poi[5:6, ],
  summary = TRUE, url_only = TRUE
)