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-11-26 21:03:00 | ORIG | 2020-11-26 21:04:00 | Castagnola, Villa Favorita | pedestrian | pedestrian | NA | NA | NA | 46 | 60 |
2 | 1 | 2020-11-26 21:04:00 | Castagnola, Villa Favorita | 2020-11-26 21:20:00 | Lugano, Stazione | transit | bus | 2 | Trasporti Pubblici Luganesi | Paradiso, Geretta | 4709 | 960 |
2 | 1 | 2020-11-26 21:20:00 | Lugano, Stazione | 2020-11-26 21:24:00 | Lugano | pedestrian | pedestrian | NA | NA | NA | 240 | 240 |
2 | 1 | 2020-11-26 21:34:00 | Lugano | 2020-11-26 23:50:00 | Zürich HB | transit | intercityTrain | EC 16 | Schweizerische Bundesbahnen SBB | Zürich HB | 195050 | 8160 |
2 | 1 | 2020-11-27 00:02:00 | Zürich HB | 2020-11-27 01:02:00 | Bern | transit | intercityTrain | IC 8 | Schweizerische Bundesbahnen SBB | Bern | 121032 | 3600 |
2 | 1 | 2020-11-27 01:12:00 | Bern | 2020-11-27 01:23:00 | Kehrsatz Nord | transit | cityTrain | S 44 | BLS AG (bls) | Thun | 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
)