
Adjust the arrival and departure times of a GTFS data (deprecated)
Source:R/adjust_arrival_departure.R
adjust_arrival_departure.RdThis function is deprecated and will be removed in a future
version; it warns once per session. Its job has moved to gtfstools: use
gtfstools::set_dwell_time() or gtfstools::set_min_dwell_time()
to edit and fix GTFS feeds before converting them. Unlike this function,
set_min_dwell_time() keeps arrivals, delays the departure and the later
times of the trip, and leaves each trip's first and last timed stops unchanged
(set_dwell_time() sets them too); neither fills blank times.
Some GTFS.zip data have issues related to arrival and departure time on stops. This function makes sure the GTFS has dis/embarking times at each stop. For each stop time row, this function applies the following steps:
If there is
arrival_timebut nodeparture_time, it creates a departure_time column by summing the arrival plus a pre-definedmin_lag.If there is
departure_timebut noarrival_time, it creates an arrival_time column by subtracting a pre-definedmin_lagfrom the departure.If there is an
arrival_timeand adeparture_timebut their difference is smaller thanmin_lag, it reduces thearrival_timeand increasesdeparture_timeso that the difference will be exactlymin_lag. Odd differences give the extra second to the departure.
Arrivals before 00:00:00 are set to 00:00:00 and the departure moved to
keep min_lag. Times are not kept increasing across consecutive stops.
The input GTFS data is not modified.
Arguments
- gtfs_data
A GTFS data created with
read_gtfs.- min_lag
Numeric. Minimum waiting time when a vehicle arrives at a stop. It can be a numeric or a units value that can be converted to seconds, rounded to whole seconds. Default is 20s.
Value
A GTFS with adjusted arrival_time and departure_time on
data.table stop_times. Stops with neither time come back with empty
strings (""), which GTFS allows for stops that are not timepoints.
Examples
poa <- read_gtfs(system.file("extdata/poa.zip", package="gtfs2gps"))
#> Unzipped the following files to /tmp/RtmpL1LF2I/gtfsio:
#> * agency.txt
#> * calendar.txt
#> * routes.txt
#> * shapes.txt
#> * stop_times.txt
#> * stops.txt
#> * trips.txt
#> Reading agency
#> Reading calendar
#> Reading routes
#> Reading shapes
#> Reading stop_times
#> Reading stops
#> Reading trips
poa <- adjust_arrival_departure(poa)
#> Warning: `adjust_arrival_departure()` is deprecated and will be removed in a future
#> version.
#> ℹ Its job has moved to gtfstools: use `gtfstools::set_dwell_time()` or
#> `gtfstools::set_min_dwell_time()` to edit and fix GTFS feeds.
#> This warning is displayed once per session.