Learn R Programming

r5r (version 0.3-3)

travel_time_matrix: Calculate travel time matrix between origin destination pairs

Description

Fast computation of travel time estimates between one or multiple origin destination pairs.

Usage

travel_time_matrix(
  r5r_core,
  origins,
  destinations,
  mode = "WALK",
  mode_egress = "WALK",
  departure_datetime = Sys.time(),
  time_window = 1L,
  percentiles = 50L,
  max_walk_dist = Inf,
  max_trip_duration = 120L,
  walk_speed = 3.6,
  bike_speed = 12,
  max_rides = 3,
  n_threads = Inf,
  verbose = TRUE
)

Arguments

r5r_core

a rJava object to connect with R5 routing engine

origins, destinations

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".

departure_datetime

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

time_window

numeric. Time window in minutes for which r5r will calculate multiple travel time matrices departing each minute. By default, the number of simulations is 5 times the size of 'time_window' set by the user. Defaults window size to '1', the function only considers 5 departure times. This parameter is only used with frequency-based GTFS files. See details for further information.

percentiles

numeric vector. Defaults to '50', returning the median travel time for a given time_window. If a numeric vector is passed, for example c(25, 50, 75), the function will return additional columns with the travel times within percentiles of trips. For example, if the 25 percentile of trips between A and B is 15 minutes, this means that 25% of all trips taken between A and B within the set time window are shorter than 15 minutes. Only the first 5 cut points of the percentiles are considered. For more details, see R5 documentation at 'https://docs.conveyal.com/analysis/methodology#accounting-for-variability'

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.

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.

Value

A data.table with travel time estimates (in minutes) between origin destination pairs by a given transport mode. Note that origins/destinations that were beyond the maximum travel time, and/or origins that were far from the street network are not returned in the data.table.

Routing algorithm:

The travel_time_matrix function uses an R5-specific extension to the RAPTOR routing algorithm (see Conway et al., 2017). This RAPTOR extension uses a systematic sample of one departure per minute over the time window set by the user in the 'time_window' parameter. A detailed description of base RAPTOR can be found in Delling et al (2015).

  • Conway, M. W., Byrd, A., & van der Linden, M. (2017). Evidence-based transit and land use sketch planning using interactive accessibility methods on combined schedule and headway-based networks. Transportation Research Record, 2653(1), 45-53.

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

Details

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

See Also

Other routing: detailed_itineraries()

Examples

Run this code
# NOT RUN {
 if (interactive()) {
library(r5r)

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

# load origin/destination points
points <- read.csv(file.path(data_path, "spo_hexgrid.csv"))[1:5,]

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

# estimate travel time matrix
ttm <- travel_time_matrix(r5r_core,
                          origins = points,
                          destinations = points,
                          mode = c("WALK", "TRANSIT"),
                          departure_datetime = departure_datetime,
                          max_walk_dist = Inf,
                          max_trip_duration = 120L)

stop_r5(r5r_core)

} 
# }

Run the code above in your browser using DataLab