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 | departure | origin | arrival | destination | type | mode | vehicle | provider | direction | distance | duration |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 1 | 2020-08-13 16:10:00 | ORIG | 2020-08-13 16:11:00 | Castagnola, Villa Favorita | pedestrian | pedestrian | NA | NA | NA | 46 | 60 |
2 | 1 | 2020-08-13 16:11:00 | Castagnola, Villa Favorita | 2020-08-13 16:25:00 | Lugano, Stazione | transit | bus | 2 | Trasporti Pubblici Luganesi | Paradiso, Geretta | 4709 | 840 |
2 | 1 | 2020-08-13 16:25:00 | Lugano, Stazione | 2020-08-13 16:29:00 | Lugano | pedestrian | pedestrian | NA | NA | NA | 240 | 240 |
2 | 1 | 2020-08-13 16:34:00 | Lugano | 2020-08-13 18:50:00 | Zürich HB | transit | intercityTrain | EC 15 | Schweizerische Bundesbahnen SBB | Zürich HB | 195216 | 8160 |
2 | 1 | 2020-08-13 19:02:00 | Zürich HB | 2020-08-13 19:58:00 | Bern | transit | intercityTrain | IC 8 | Schweizerische Bundesbahnen SBB | Brig | 121032 | 3360 |
2 | 1 | 2020-08-13 20:02:00 | Bern | 2020-08-13 20:13:00 | Kehrsatz Nord | transit | cityTrain | S 3 | BLS AG (bls) | Belp | 8668 | 660 |
Print the intermodal routes on an interactive leaflet map:
mapview(intermodal_routes,
zcol = "mode",
layer.name = "Intermodal route",
map.types = c("Esri.WorldTopoMap"),
homebutton = FALSE
)