Title: | Routing with 'GTFS' (General Transit Feed Specification) Data |
---|---|
Description: | Use 'GTFS' (General Transit Feed Specification) data for routing from nominated start and end stations, for extracting 'isochrones', and travel times from any nominated start station to all other stations. |
Authors: | Mark Padgham [aut, cre], Marcin Stepniak [aut] , Alexandra Kapp [ctb] |
Maintainer: | Mark Padgham <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2.001 |
Built: | 2024-10-07 04:03:50 UTC |
Source: | https://github.com/urbananalyst/gtfsrouter |
Sample GTFS data from Verkehrsverbund Berlin-Brandenburg street, reduced to U and S Bahn only (underground and overground trains), and between the hours of 12:00-13:00. Only those components of the GTFS data necessary for routing have been retained. Note that non-ASCII characters have been removed from these data, so umlauts are simply removed and eszetts become "ss". The package will nevertheless work with full GTFS feeds and non-ASCII (UTF-8) characters.
A list of five data.table items necessary for routing:
calendar
routes
trips
stop_times
stops
transfers
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
.
Can be re-created with the script in https://github.com/UrbanAnalyst/gtfsrouter/blob/master/data-raw/data-script.Rmd.
# 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)
# 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)
Write a zip archive of the internal package data, berlin_gtfs to
a file named "vbb.zip" to tempdir()
.
berlin_gtfs_to_zip()
berlin_gtfs_to_zip()
Path to newly created zip file
Other extract:
extract_gtfs()
,
gtfs_timetable()
Extract data from a GTFS zip
archive.
extract_gtfs(filename = NULL, quiet = FALSE, stn_suffixes = NULL)
extract_gtfs(filename = NULL, quiet = FALSE, stn_suffixes = NULL)
filename |
Name of GTFS archive |
quiet |
If |
stn_suffixes |
Any values provided will be removed from terminal
characters of station IDs. Useful for feeds like NYC for which some stations
are appended with values of "N" and "S" to indicate directions. Specifying
|
List of several data.table objects corresponding to the tables present in the nominated GTFS data set.
Column types in each table of the returned object conform to GTFS
standards (https://developers.google.com/transit/gtfs/reference),
except that "Time" fields in the "stop_times" table are converted to integer
values, rather than as character or "Time" objects ("HH:MM:SS"). These can be
converted back to comply with GTFS standards by applying the hms::hms()
function to the two time columns of the "stop_times" table.
Other extract:
berlin_gtfs_to_zip()
,
gtfs_timetable()
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)
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)
Convert a GTFS 'frequencies' table to equivalent 'stop_times' that can be used for routing.
frequencies_to_stop_times(gtfs)
frequencies_to_stop_times(gtfs)
gtfs |
A set of GTFS data returned from extract_gtfs. |
The input GTFS data with data from the 'frequencies' table converted
to equivalent 'arrival_time' and 'departure_time' values in stop_times
.
Other augment:
gtfs_transfer_table()
Use local environmental variables specifying home and work stations and locations of locally-stored GTFS data to route from work to home location with next available service.
go_home(wait = 0, start_time)
go_home(wait = 0, start_time)
wait |
An integer specifying the n-th next service. That is, |
start_time |
If given, search for connections after specified time; if not given, search for connections from current time. |
This function, and the complementary function go_to_work,
requires three local environmental variables specifying the names of home and
work stations, and the location on local storage of the GTFS data set to be
used for routing. These are respectively called gtfs_home
, gtfs_work
, and
gtfs_data
. This data set must also be pre-processed using the
process_gtfs_local function.
See Startup for details on how to set environmental variables.
Briefly, this can be done in two main ways: By setting them at the start of
each session, in which case the variables may be set with:
Sys.setenv ("gtfs_home" = "<my home station>")
Sys.setenv ("gtfs_work" = "<my work station>")
Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip")
Alternatively, to set these automatically for each session, paste those lines
into the file ~/.Renviron
- that is, a file named ".Renviron" in the user's
home directory.
The process_gtfs_local function reduces the GTFS data set to the minimal possible size necessary for local routing. GTFS data are nevertheless typically quite large, and both the go_home and go_to_work functions may take some time to execute. Most of this time is devoted to loading the data in to the current workspace and as such is largely unavoidable.
A data.frame
specifying the next available route from work to home.
Other additional:
go_to_work()
,
process_gtfs_local()
,
summary.gtfs()
## Not run: # For general use, please set these three variables: Sys.setenv ("gtfs_home" = "<my home station>") Sys.setenv ("gtfs_work" = "<my work station>") Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip") # The following illustrate use with sample data bundled with package Sys.setenv ("gtfs_home" = "Tempelhof") Sys.setenv ("gtfs_work" = "Alexanderplatz") Sys.setenv ("gtfs_data" = file.path (tempdir (), "vbb.zip")) process_gtfs_local () # If not already done go_home (start_time = "12:00") # next available service after 12:00 go_home (3, start_time = "12:00") # Wait until third service after that # Generally, `start_time` will not be specified, in which case `go_home` will # return next available service from current system time, so calls will # generally be as simple as: go_home () go_home (3) ## End(Not run)
## Not run: # For general use, please set these three variables: Sys.setenv ("gtfs_home" = "<my home station>") Sys.setenv ("gtfs_work" = "<my work station>") Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip") # The following illustrate use with sample data bundled with package Sys.setenv ("gtfs_home" = "Tempelhof") Sys.setenv ("gtfs_work" = "Alexanderplatz") Sys.setenv ("gtfs_data" = file.path (tempdir (), "vbb.zip")) process_gtfs_local () # If not already done go_home (start_time = "12:00") # next available service after 12:00 go_home (3, start_time = "12:00") # Wait until third service after that # Generally, `start_time` will not be specified, in which case `go_home` will # return next available service from current system time, so calls will # generally be as simple as: go_home () go_home (3) ## End(Not run)
Use local environmental variables specifying home and work stations and locations of locally-stored GTFS data to route from home to work location with next available service.
go_to_work(wait = 0, start_time)
go_to_work(wait = 0, start_time)
wait |
An integer specifying the n-th next service. That is, |
start_time |
If given, search for connections after specified time; if not given, search for connections from current time. |
This function, and the complementary function go_to_work,
requires three local environmental variables specifying the names of home and
work stations, and the location on local storage of the GTFS data set to be
used for routing. These are respectively called gtfs_home
, gtfs_work
, and
gtfs_data
. This data set must also be pre-processed using the
process_gtfs_local function.
See Startup for details on how to set environmental variables.
Briefly, this can be done in two main ways: By setting them at the start of
each session, in which case the variables may be set with:
Sys.setenv ("gtfs_home" = "<my home station>")
Sys.setenv ("gtfs_work" = "<my work station>")
Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip")
Alternatively, to set these automatically for each session, paste those lines
into the file ~/.Renviron
- that is, a file named ".Renviron" in the user's
home directory.
The process_gtfs_local function reduces the GTFS data set to the minimal possible size necessary for local routing. GTFS data are nevertheless typically quite large, and both the go_home and go_to_work functions may take some time to execute. Most of this time is devoted to loading the data in to the current workspace and as such is largely unavoidable.
A data.frame
specifying the next available route from work to home.
Other additional:
go_home()
,
process_gtfs_local()
,
summary.gtfs()
## Not run: # For general use, please set these three variables: Sys.setenv ("gtfs_home" = "<my home station>") Sys.setenv ("gtfs_work" = "<my work station>") Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip") # The following illustrate use with sample data bundled with package Sys.setenv ("gtfs_home" = "Tempelhof") Sys.setenv ("gtfs_work" = "Alexanderplatz") Sys.setenv ("gtfs_data" = file.path (tempdir (), "vbb.zip")) process_gtfs_local () # If not already done go_to_work (start_time = "12:00") # next available service after 12:00 go_to_work (3, start_time = "12:00") # Wait until third service after that # Generally, `start_time` will not be specified, in which case `go_to_work` # will return next available service from current system time, so calls will # generally be as simple as: go_to_work () go_to_work (3) ## End(Not run)
## Not run: # For general use, please set these three variables: Sys.setenv ("gtfs_home" = "<my home station>") Sys.setenv ("gtfs_work" = "<my work station>") Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip") # The following illustrate use with sample data bundled with package Sys.setenv ("gtfs_home" = "Tempelhof") Sys.setenv ("gtfs_work" = "Alexanderplatz") Sys.setenv ("gtfs_data" = file.path (tempdir (), "vbb.zip")) process_gtfs_local () # If not already done go_to_work (start_time = "12:00") # next available service after 12:00 go_to_work (3, start_time = "12:00") # Wait until third service after that # Generally, `start_time` will not be specified, in which case `go_to_work` # will return next available service from current system time, so calls will # generally be as simple as: go_to_work () go_to_work (3) ## End(Not run)
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_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)
# 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)
Calculate a vector of headway values – that is, time intervals between consecutive services – for all routes between two specified stations.
gtfs_route_headway( gtfs, from, to, from_to_are_ids = FALSE, grep_fixed = TRUE, quiet = FALSE )
gtfs_route_headway( gtfs, from, to, from_to_are_ids = FALSE, grep_fixed = TRUE, 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. |
from_to_are_ids |
Set to |
grep_fixed |
If |
quiet |
If |
A single vector of integer values containing headways between all services across a single 24-hour period
Other main:
gtfs_route()
,
gtfs_traveltimes()
Convert GTFS data into format able to be used to calculate routes.
gtfs_timetable( gtfs, day = NULL, date = NULL, route_pattern = NULL, quiet = FALSE )
gtfs_timetable( gtfs, day = NULL, date = NULL, route_pattern = NULL, quiet = FALSE )
gtfs |
A set of GTFS data returned from extract_gtfs. |
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 - unless the following 'date' parameter is give. |
date |
Some systems do not specify days of the week within their 'calendar' table; rather they provide full timetables for specified calendar dates via a 'calendar_date' table. Providing a date here as a single 8-digit number representing 'yyyymmdd' will filter the data to the specified date. Also the 'calendar' is scanned for services that operate on the selected date. Therefore also a merge of feeds that combine 'calendar' and 'calendar_dates' options is covered. |
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 negative the |
quiet |
Set to |
The input data with an addition items, timetable
, stations
, and
trips
, containing data formatted for more efficient use with
gtfs_route (see Note).
This function is merely provided to speed up calls to the primary
function, gtfs_route. If the input data to that function do not
include a formatted timetable
, it will be calculated anyway, but queries in
that case will generally take longer.
Other extract:
berlin_gtfs_to_zip()
,
extract_gtfs()
# 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)
# 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)
Construct a transfer table for a GTFS feed.
gtfs_transfer_table( gtfs, d_limit = 200, min_transfer_time = 120, network = NULL, network_times = FALSE, quiet = FALSE )
gtfs_transfer_table( gtfs, d_limit = 200, min_transfer_time = 120, network = NULL, network_times = FALSE, quiet = FALSE )
gtfs |
A GTFS feed obtained from the extract_gtfs function. |
d_limit |
Upper straight-line distance limit in metres for transfers. |
min_transfer_time |
Minimum time in seconds for transfers; all values below this will be replaced with this value, particularly all those defining in-place transfers where stop longitudes and latitudes remain identical. |
network |
Optional Open Street Map representation of the street network encompassed by the GTFS feed (see Examples). |
network_times |
If |
quiet |
Set to |
Modified version of the gtfs
input with additional transfers table.
Other augment:
frequencies_to_stop_times()
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f, quiet = TRUE) g <- gtfs_transfer_table (g, d_limit = 200) # g$transfers then has fewer rows than original, because original transfer # table contains duplicated rows. data.table::setDTthreads (nthr)
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f, quiet = TRUE) g <- gtfs_transfer_table (g, d_limit = 200) # g$transfers then has fewer rows than original, because original transfer # table contains duplicated rows. data.table::setDTthreads (nthr)
Travel times from a nominated station departing at a nominated time to every other reachable station in a system.
gtfs_traveltimes( gtfs, from, start_time_limits, day = NULL, from_is_id = FALSE, grep_fixed = TRUE, route_pattern = NULL, minimise_transfers = FALSE, max_traveltime = 60 * 60, quiet = FALSE )
gtfs_traveltimes( gtfs, from, start_time_limits, day = NULL, from_is_id = FALSE, grep_fixed = TRUE, route_pattern = NULL, minimise_transfers = FALSE, max_traveltime = 60 * 60, quiet = FALSE )
gtfs |
A set of GTFS data returned from extract_gtfs or, for more efficient queries, pre-processed with gtfs_timetable. |
from |
Name, ID, or approximate (lon, lat) coordinates of start station
(as |
start_time_limits |
A vector of two integer values denoting the earliest and latest departure times in seconds for the traveltime values. |
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 |
from_is_id |
Set to |
grep_fixed |
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 |
minimise_transfers |
If |
max_traveltime |
The maximal traveltime to search for, specified in seconds (with default of 1 hour). See note for details. |
quiet |
Set to |
A data.frame
of travel times and required numbers of transfers to
all stations reachable from the given from
station. Additional columns
include "start_time" of connection, and information on destination stops
including "id" numbers, names, and geographical coordinates.
Higher values of max_traveltime
will return traveltimes for greater
numbers of stations, but may lead to considerably longer calculation times.
For repeated usage, it is recommended to first establish a value sufficient
to reach all or most stations desired for a particular query, rather than set
max_traveltime
to an arbitrarily high value.
Other main:
gtfs_route_headway()
,
gtfs_route()
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f) g <- gtfs_timetable (g) from <- "Alexanderplatz" start_times <- 12 * 3600 + c (0, 60) * 60 # 8:00-9:00 res <- gtfs_traveltimes (g, from, start_times) data.table::setDTthreads (nthr)
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f) g <- gtfs_timetable (g) from <- "Alexanderplatz" start_times <- 12 * 3600 + c (0, 60) * 60 # 8:00-9:00 res <- gtfs_traveltimes (g, from, start_times) data.table::setDTthreads (nthr)
Routing engine for GTFS (General Transit Feed Specification) data, including one-to-one and one-to-many routing routines.
gtfs_route()
: Route between given start and end stations using a
nominated GTFS data set.
go_home()
: Automatic routing between work and home stations specified
with local environmental variables
go_to_work()
: Automatic routing between work and home stations
specified with local environmental variables
gtfs_traveltimes()
: One-to-many routing from a nominated start
station to all stations reachable within a specified travel duration.
Maintainer: Mark Padgham [email protected]
Authors:
Marcin Stepniak [email protected] (ORCID)
Other contributors:
Alexandra Kapp [email protected] [contributor]
Useful links:
Report bugs at https://github.com/UrbanAnalyst/gtfsrouter/issues
Process a local GTFS data set with environmental variables described in
go_home into a condensed version for use in go_home and
go_to_work
functions.
process_gtfs_local(expand = 2)
process_gtfs_local(expand = 2)
expand |
The data set is reduced to the bounding box defined by the home and work stations, expanded by this multiple. If the function appears to behave strangely, try re-running this function with a higher value of this parameter. |
No return value. The function saves processed data to a local cache.
Other additional:
go_home()
,
go_to_work()
,
summary.gtfs()
summary.gtfs
## S3 method for class 'gtfs' summary(object, ...)
## S3 method for class 'gtfs' summary(object, ...)
object |
A |
... |
ignored here |
Nothing; this function only prints a summary to the console.
Other additional:
go_home()
,
go_to_work()
,
process_gtfs_local()
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f) summary (g) g <- gtfs_timetable (g) summary (g) # also summarizes additional timetable information data.table::setDTthreads (nthr)
# Examples must be run on single thread only: nthr <- data.table::setDTthreads (1) berlin_gtfs_to_zip () f <- file.path (tempdir (), "vbb.zip") g <- extract_gtfs (f) summary (g) g <- gtfs_timetable (g) summary (g) # also summarizes additional timetable information data.table::setDTthreads (nthr)