View source: R/get_trip_length.R
get_trip_length | R Documentation |
Returns the length of each specified trip_id
, based either on the shapes
or the stop_times
file (or both).
get_trip_length(gtfs, trip_id = NULL, file = NULL, unit = "km")
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 |
A data.table
containing the length of each specified trip.
Please check get_trip_geometry()
documentation to understand how geometry
generation, and consequently length calculation, differs depending on the
chosen file.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.