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 2022-07-24 16:05:00 ORIG 2022-07-24 16:13:00 Littau, Längweiher pedestrian pedestrian NA NA NA 466 480
1 1 2 2022-07-24 16:13:00 Littau, Längweiher 2022-07-24 16:24:00 Bahnhof transit bus 12 Verkehrsbetriebe Luzern AG Luzern, Bahnhof 3415 660
1 1 3 2022-07-24 16:24:00 Bahnhof 2022-07-24 16:29:00 Luzern pedestrian pedestrian NA NA NA 270 300
1 1 4 2022-07-24 16:30:00 Luzern 2022-07-24 17:47:00 Basel SBB transit intercityTrain IR27 Schweizerische Bundesbahnen SBB Basel SBB 94766 4620
1 1 5 2022-07-24 17:47:00 Basel SBB 2022-07-24 17:51:00 Bahnhof SBB pedestrian pedestrian NA NA NA 228 240
1 1 6 2022-07-24 17:53:00 Bahnhof SBB 2022-07-24 18:13:00 Basel, Kleinhüningen transit lightRail 8 Basler Verkehrsbetriebe Basel, Kleinhüningen 4516 1200

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