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,
  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, default = -1).

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.

Note

As it is not possible to match the "maneuvers" to the "connections-sections" in the API response using the section id (sec_id), the returned geometries of walking sections are straight lines between the station (or origin and destination) points instead of routed lines on the pedestrian network. The walking segments can be routed in hindsight using the route function with mode set to "pedestrian".

References

HERE Public Transit API: Transit Route

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 )