get_trip_length {gtfstools} | R Documentation |
Get trip length
Description
Returns the length of each specified trip_id
, based either on the shapes
or the stop_times
file (or both).
Usage
get_trip_length(gtfs, trip_id = NULL, file = NULL, unit = "km")
Arguments
gtfs |
A GTFS object, as created by |
trip_id |
A character vector including the |
file |
A character vector specifying the file from which lengths should
be calculated (either one of or both |
unit |
A string representing the unit in which lengths are desired.
Either |
Value
A data.table
containing the length of each specified trip.
Details
Please check get_trip_geometry()
documentation to understand how geometry
generation, and consequently length calculation, differs depending on the
chosen file.
Examples
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
trip_length <- get_trip_length(gtfs)
head(trip_length)
# the above is identical to
trip_length <- get_trip_length(gtfs, file = c("shapes", "stop_times"))
head(trip_length)
trip_ids <- c("CPTM L07-0", "2002-10-0")
trip_length <- get_trip_length(gtfs, trip_id = trip_ids)
trip_length