gtfs_route | R Documentation |
Calculate single route between a start and end station departing at or after a specified time.
gtfs_route(
gtfs,
from,
to,
start_time = NULL,
day = NULL,
route_pattern = NULL,
earliest_arrival = TRUE,
include_ids = FALSE,
grep_fixed = TRUE,
max_transfers = NA,
from_to_are_ids = FALSE,
quiet = FALSE
)
gtfs |
A set of GTFS data returned from extract_gtfs or, for more efficient queries, pre-processed with gtfs_timetable. |
from |
Names, IDs, or approximate (lon, lat) coordinates of start
stations (as |
to |
Corresponding Names, IDs, or coordinates of end station. |
start_time |
Desired departure time at |
day |
Day of the week on which to calculate route, either as an
unambiguous string (so "tu" and "th" for Tuesday and Thursday), or a number
between 1 = Sunday and 7 = Saturday. If not given, the current day will be
used. (Not used if |
route_pattern |
Using only those routes matching given pattern, for
example, "^U" for routes starting with "U" (as commonly used for underground
or subway routes. To negate the |
earliest_arrival |
If |
include_ids |
If |
grep_fixed |
If |
max_transfers |
If not |
from_to_are_ids |
Set to |
quiet |
Set to |
For single (from, to) values, a data.frame
describing the route,
with each row representing one stop. For multiple (from, to) values, a list
of data.frames
, each of which describes one route between the i'th start
and end stations (from
and to
values). Origin and destination stations
for which no route is possible return NULL
.
This function will by default calculate the route that arrives earliest
at the specified destination, although this may depart later than the
earliest departing service. Routes which depart at the earliest possible time
can be calculated by setting earliest_arrival = FALSE
.
Other main:
gtfs_route_headway()
,
gtfs_traveltimes()
# Examples must be run on single thread only:
nthr_dt <- data.table::setDTthreads (1)
nthr_omp <- Sys.getenv ("OMP_THREAD_LIMIT")
Sys.setenv ("OMP_THREAD_LIMIT" = 1L)
berlin_gtfs_to_zip () # Write sample feed from Berlin, Germany to tempdir
f <- file.path (tempdir (), "vbb.zip") # name of feed
gtfs <- extract_gtfs (f)
from <- "Innsbrucker Platz" # U-bahn station, not "S"
to <- "Alexanderplatz"
start_time <- 12 * 3600 + 120 # 12:02
route <- gtfs_route (gtfs, from = from, to = to, start_time = start_time)
# Specify day of week
route <- gtfs_route (
gtfs,
from = from,
to = to,
start_time = start_time,
day = "Sunday"
)
# specify travel by "U" = underground only
route <- gtfs_route (
gtfs,
from = from,
to = to,
start_time = start_time,
day = "Sunday",
route_pattern = "^U"
)
# specify travel by "S" = street-level only (not underground)
route <- gtfs_route (
gtfs,
from = from,
to = to,
start_time = start_time,
day = "Sunday",
route_pattern = "^S"
)
# Route queries are generally faster if the GTFS data are pre-processed with
# `gtfs_timetable()`:
gt <- gtfs_timetable (gtfs, day = "Sunday", route_pattern = "^S")
route <- gtfs_route (gt, from = from, to = to, start_time = start_time)
data.table::setDTthreads (nthr_dt)
Sys.setenv ("OMP_THREAD_LIMIT" = nthr_omp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.