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-10-20 06:42:00 | ORIG | 2020-10-20 07:15:00 | Lugano Città TPL | pedestrian | pedestrian | NA | NA | NA | 1971 | 1980 |
2 | 1 | 2020-10-20 07:15:00 | Lugano Città TPL | 2020-10-20 07:17:00 | Lugano Stazione TPL | transit | inclined | 256 | Trasporti Pubblici Luganesi SA | Lugano Stazione TPL | 228 | 120 |
2 | 1 | 2020-10-20 07:17:00 | Lugano Stazione TPL | 2020-10-20 07:20:00 | Lugano | pedestrian | pedestrian | NA | NA | NA | 180 | 180 |
2 | 1 | 2020-10-20 07:32:00 | Lugano | 2020-10-20 09:50:00 | Zürich HB | transit | intercityTrain | IC 2 | Schweizerische Bundesbahnen SBB | Zürich HB | 195050 | 8280 |
2 | 1 | 2020-10-20 10:02:00 | Zürich HB | 2020-10-20 10:58:00 | Bern | transit | intercityTrain | IC 8 | Schweizerische Bundesbahnen SBB | Brig | 121032 | 3360 |
2 | 1 | 2020-10-20 11:02:00 | Bern | 2020-10-20 11: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
)