View source: R/get_distances.R
| get_distances | R Documentation |
The 'get_distances' function calculates distances within a 'wizardgtfs' object based on various methods. Depending on the 'method' chosen, it can calculate average route distances, trip-specific distances, or detailed distances between stops.
get_distances(gtfs, method = "by_trip", trips = "all")
gtfs |
A GTFS object, ideally of class 'wizardgtfs'. If it is not of this class, it will be converted. |
method |
A character string indicating the calculation method. Choices are:
|
trips |
A character vector of trip IDs to consider. When set to 'all', includes all trips. |
The function calls specific sub-functions based on the selected method:
- "by_route": Calculates average distances per route.
- "by_trip": Calculate distances per trip.
- "detailed": Calculates detailed stop-to-stop distances within each route. Note that this method may be slow for large datasets.
Legacy dotted values remain accepted. If an invalid 'method' is provided, the function defaults to '"by_trip"' and issues a warning.
A data frame with calculated distances based on the specified method:
Returns a summary by route and direction with trip counts, average distance, service pattern, and pattern frequency.
Returns trip distance with route, direction, service pattern, and pattern frequency.
Returns a data frame with columns: 'shape_id', 'from_stop_id', 'to_stop_id', and 'distance'.
[GTFSwizard::as_wizardgtfs()], [GTFSwizard::get_servicepattern()]
# Calculate average route distances
distances_by_route <- get_distances(gtfs = for_rail_gtfs, method = "by_route", trips = 'all')
# Calculate distances by trip
distances_by_trip <- get_distances(gtfs = for_rail_gtfs, method = "by_trip", trips = 'all')
# Calculate detailed distances between stops
detailed_distances <- get_distances(gtfs = for_rail_gtfs, method = "detailed", trips = 'all')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.