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-01-31 13:05:00 ORIG 2021-01-31 13:13:00 Littau, Längweiher pedestrian pedestrian NA NA NA 473 480
1 1 2 2021-01-31 13:13:00 Littau, Längweiher 2021-01-31 13:24:00 Bahnhof transit bus 12 vbl verkehrsbetriebe luzern ag Luzern, Bahnhof 3440 660
1 1 3 2021-01-31 13:24:00 Bahnhof 2021-01-31 13:29:00 Luzern pedestrian pedestrian NA NA NA 270 300
1 1 4 2021-01-31 13:30:00 Luzern 2021-01-31 14:45:00 Basel SBB transit intercityTrain IR IR27 Schweizerische Bundesbahnen SBB Basel SBB 92286 4500
1 1 5 2021-01-31 14:45:00 Basel SBB 2021-01-31 14:49:00 Bahnhof SBB pedestrian pedestrian NA NA NA 228 240
1 1 6 2021-01-31 14:53:00 Bahnhof SBB 2021-01-31 15:12:00 Basel, Kleinhüningen transit lightRail 8 Basler Verkehrsbetriebe Basel, Kleinhüningen 4551 1140

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