Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

detailed_itineraries

Calculate detailed itineraries between origin destination pairs


Description

Fast computation of (multiple) detailed itineraries between one or many origin destination pairs.

Usage

detailed_itineraries(
  r5r_core,
  origins,
  destinations,
  mode = "WALK",
  mode_egress = "WALK",
  departure_datetime = Sys.time(),
  max_walk_dist = Inf,
  max_trip_duration = 120L,
  walk_speed = 3.6,
  bike_speed = 12,
  max_rides = 3,
  max_lts = 2,
  shortest_path = TRUE,
  n_threads = Inf,
  verbose = TRUE,
  drop_geometry = FALSE
)

Arguments

r5r_core

rJava object to connect with R5 routing engine

origins, destinations

either a spatial sf POINT object or a data.frame containing the columns 'id', 'lon', 'lat'

mode

string. Transport modes allowed for the trips. Defaults to "WALK". See details for other options.

mode_egress

string. Transport mode used after egress from public transport. It can be either 'WALK', 'BICYCLE', or 'CAR'. Defaults to "WALK". Ignored when public transport is not used.

departure_datetime

POSIXct object. If working with public transport networks, please check calendar.txt within the GTFS file for valid dates.

max_walk_dist

numeric. Maximum walking distance (in meters) for the whole trip. Defaults to no restrictions on walking, as long as max_trip_duration is respected.

max_trip_duration

numeric. Maximum trip duration in minutes. Defaults to 120 minutes (2 hours).

walk_speed

numeric. Average walk speed in km/h. Defaults to 3.6 km/h.

bike_speed

numeric. Average cycling speed in km/h. Defaults to 12 km/h.

max_rides

numeric. The max number of public transport rides allowed in the same trip. Defaults to 3.

max_lts

numeric (between 1 and 4). The maximum level of traffic stress that cyclists will tolerate. A value of 1 means cyclists will only travel through the quietest streets, while a value of 4 indicates cyclists can travel through any road. Defaults to 2. See details for more information.

shortest_path

logical. Whether the function should only return the fastest route alternative (the default) or multiple alternatives.

n_threads

numeric. The number of threads to use in parallel computing. Defaults to use all available threads (Inf).

verbose

logical. TRUE to show detailed output messages (the default) or FALSE to show only eventual ERROR messages.

drop_geometry

logical. Indicates whether R5 should drop segment's geometry column. It can be helpful for saving memory.

Value

A LINESTRING sf with detailed information about the itineraries between specified origins and destinations. Distances are in meters and travel times are in minutes.

Transpor modes:

R5 allows for multiple combinations of transport modes. The options include:

Transit modes

TRAM, SUBWAY, RAIL, BUS, FERRY, CABLE_CAR, GONDOLA, FUNICULAR. The option 'TRANSIT' automatically considers all public transport modes available.

Non transit modes

WALK, BICYCLE, CAR, BICYCLE_RENT, CAR_PARK

max_lts, Maximum Level of Traffic Stress:

When cycling is enabled in R5, setting max_lts will allow cycling only on streets with a given level of danger/stress. Setting max_lts to 1, for example, will allow cycling only on separated bicycle infrastructure or low-traffic streets; routing will revert to walking when traversing any links with LTS exceeding 1. Setting max_lts to 3 will allow cycling on links with LTS 1, 2, or 3.

The default methodology for assigning LTS values to network edges is based on commonly tagged attributes of OSM ways. See more info about LTS at https://docs.conveyal.com/learn-more/traffic-stress. In summary:

  • LTS 1: Tolerable for children. This includes low-speed, low-volume streets, as well as those with separated bicycle facilities (such as parking-protected lanes or cycle tracks).

  • LTS 2: Tolerable for the mainstream adult population. This includes streets where cyclists have dedicated lanes and only have to interact with traffic at formal crossing.

  • LTS 3: Tolerable for “enthused and confident” cyclists. This includes streets which may involve close proximity to moderate- or high-speed vehicular traffic.

  • LTS 4: Tolerable for only “strong and fearless” cyclists. This includes streets where cyclists are required to mix with moderate- to high-speed vehicular traffic.

Routing algorithm:

The detailed_itineraries function uses an R5-specific extension to the McRAPTOR routing algorithm to find paths that are optimal or less than optimal, with some heuristics around multiple access modes, riding the same patterns, etc. The specific extension to McRAPTOR to do suboptimal path routing are not documented yet, but a detailed description of base McRAPTOR can be found in Delling et al (2015).

  • Delling, D., Pajor, T., & Werneck, R. F. (2015). Round-based public transit routing. Transportation Science, 49(3), 591-604.

See Also

Other routing: travel_time_matrix()

Examples

if (interactive()) {
library(r5r)

# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = data_path)

# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))

# inputs
departure_datetime <- as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S")

dit <- detailed_itineraries(r5r_core,
                            origins = points[10,],
                            destinations = points[12,],
                            mode = c("WALK", "TRANSIT"),
                            departure_datetime = departure_datetime,
                            max_walk_dist = 1000,
                            max_trip_duration = 120L)

stop_r5(r5r_core)
}

r5r

Rapid Realistic Routing with 'R5'

v0.4.0
MIT + file LICENSE
Authors
Marcus Saraiva [aut] (<https://orcid.org/0000-0001-6218-2338>), Rafael H. M. Pereira [aut, cre] (<https://orcid.org/0000-0003-2125-7465>), Daniel Herszenhut [aut] (<https://orcid.org/0000-0001-8066-1105>), Carlos Kaue Vieira Braga [aut] (<https://orcid.org/0000-0002-6104-7297>), Matthew Wigginton Conway [aut] (<https://orcid.org/0000-0002-1210-2982>), Ipea - Institue for Applied Economic Research [cph, fnd]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.