Intermodal Routing API

Routing intermodal directions between locations based on the ‘HERE Intermodal Routing’ API.

Intermodal routes

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
intermodal_routes <- route(
  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-09-26 18:20:00 ORIG 2021-09-26 18:28:00 Littau, Längweiher pedestrian pedestrian NA NA NA 473 480
1 1 2 2021-09-26 18:28:00 Littau, Längweiher 2021-09-26 18:39:00 Bahnhof transit bus 12 Verkehrsbetriebe Luzern AG Luzern, Bahnhof 3457 660
1 1 3 2021-09-26 18:39:00 Bahnhof 2021-09-26 18:44:00 Luzern pedestrian pedestrian NA NA NA 270 300
1 1 4 2021-09-26 18:54:00 Luzern 2021-09-26 19:56:00 Basel SBB transit intercityTrain IR26 Schweizerische Südostbahn (sob) Basel SBB 94763 3720
1 1 5 2021-09-26 19:56:00 Basel SBB 2021-09-26 19:57:00 NA pedestrian pedestrian NA NA NA 66 60
1 1 6 2021-09-26 19:57:00 NA 2021-09-26 20: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::mapview(intermodal_routes,
                   zcol = "mode",
                   layer.name = "Intermodal route",
                   map.types = c("Esri.WorldTopoMap"),
                   homebutton = FALSE
  )
}

API Reference