Routing intermodal directions between locations based on the ‘HERE Intermodal Routing’ API.
In order to calculate route geometries (LINESTRING
) between pairs of points using the ‘HERE Intermodal Routing API’ the function intermodal_route()
is used. The function takes origin and destination locations as sf
objects containing geometries of type POINT
as input. Routes can be limited to a maximum number of allowed transfers (includes mode changes and public transit transfers), by specifying the transfer
parameter.
# Request routes
<- route(
intermodal_routes origin = poi[1:3, ],
destination = poi[4:6, ]
)
The id
column corresponds to the row of the input locations (origin
and destination
) and the rank
column enumerates the alternative routes. The maximum number of alternatives can be set by the results
parameter. Each row in the returned sf
object corresponds to a route section with a transport mode in a vehicle without a transfer.
id | rank | section | departure | origin | arrival | destination | type | mode | vehicle | provider | direction | distance | duration |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 2021-07-17 14:27:00 | ORIG | 2021-07-17 14:35:00 | Littau, Längweiher | pedestrian | pedestrian | NA | NA | NA | 473 | 480 |
1 | 1 | 2 | 2021-07-17 14:35:00 | Littau, Längweiher | 2021-07-17 14:47:00 | Bahnhof | transit | bus | 12 | vbl verkehrsbetriebe luzern ag | Luzern, Bahnhof | 3457 | 720 |
1 | 1 | 3 | 2021-07-17 14:47:00 | Bahnhof | 2021-07-17 14:52:00 | Luzern | pedestrian | pedestrian | NA | NA | NA | 270 | 300 |
1 | 1 | 4 | 2021-07-17 14:54:00 | Luzern | 2021-07-17 15:56:00 | Basel SBB | transit | intercityTrain | IR IR26 | Schweizerische Südostbahn (sob) | Basel SBB | 94781 | 3720 |
1 | 1 | 5 | 2021-07-17 15:56:00 | Basel SBB | 2021-07-17 15:57:00 | NA | pedestrian | pedestrian | NA | NA | NA | 66 | 60 |
1 | 1 | 6 | 2021-07-17 15:57:00 | NA | 2021-07-17 16:15:00 | DEST | rented | bicycle | NA | Swiss Federal Office of Energy | NA | 4253 | 1080 |
Print the intermodal routes on an interactive leaflet map:
if (requireNamespace("mapview", quietly = TRUE)) {
::mapview(intermodal_routes,
mapviewzcol = "mode",
layer.name = "Intermodal route",
map.types = c("Esri.WorldTopoMap"),
homebutton = FALSE
) }