gtfstools (version 0.1.0)

get_trip_speed: Get trip speed

Description

Returns the speed of each specified trip_id, based on the geometry created from either on the shapes or the stop_times file (or both).

Usage

get_trip_speed(gtfs, trip_id = NULL, file = "shapes", unit = "km/h")

Arguments

gtfs

A GTFS object as created by read_gtfs.

trip_id

A string vector including the trip_ids to have their speeds calculated. If NULL (the default), the function calculates the speed of every trip_id in the GTFS.

file

The file from which geometries should be generated, either shapes and stop_times (geometries are used to calculate the length of a trip). Defaults to shapes.

unit

A string representing the unit in which the speeds are desired. Either "km/h" (the default) or "m/s".

Value

A data.table containing the duration of each specified trip and the file from which geometries were generated.

Details

Please check get_trip_geometry documentation to understand how geometry generation differs depending on the chosen file.

See Also

get_trip_geometry

Examples

Run this code
# NOT RUN {
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")

gtfs <- read_gtfs(data_path)

trip_speed <- get_trip_speed(gtfs)
head(trip_speed)

trip_ids <- c("CPTM L07-0", "2002-10-0")
trip_speed <- get_trip_speed(gtfs, trip_ids)
trip_speed

trip_speed <- get_trip_speed(
  gtfs,
  trip_ids,
  file = c("shapes", "stop_times")
)
trip_speed

trip_speed <- get_trip_speed(gtfs, trip_ids, unit = "m/s")
trip_speed

# }

Run the code above in your browser using DataLab