The `get_corridor` function identifies and extracts high-density transit corridors based on trip frequency between stops. It groups segments into connected corridors, and filters them based on a minimum length criterion.
get_corridor(gtfs, i = 0.01, min.length = 1500)
An `sf` object containing the following columns:
A unique identifier for each corridor, prefixed with "corridor-".
A list of stop IDs included in each corridor.
A list of trip IDs included in each corridor.
The total length of the corridor, in meters.
The spatial representation of the corridor as an `sf` linestring object.
A GTFS object, preferably of class `wizardgtfs`. If not, the function will attempt to convert it using `GTFSwizard::as_wizardgtfs()`.
A numeric value representing the percentile threshold for selecting high-density segments. Defaults to `0.01` (top 1% of segments by trip frequency).
A numeric value specifying the minimum corridor length (in meters) to retain. Defaults to `1500`.
The function performs the following steps:
Filters and orders `stop_times` data to identify consecutive stops (`stop_from` and `stop_to`) for each trip.
Counts the number of trips between each stop pair and selects the top `i` percentile of segments by trip frequency.
Groups spatially connected segments into corridors using graph theory and adjacency matrices.
Filters corridors by the minimum length (`min.length`).
Returns the resulting corridors with their metadata and geometry.
[GTFSwizard::as_wizardgtfs()]
corridors <- get_corridor(for_bus_gtfs, i = 0.02, min.length = 2000)
Run the code above in your browser using DataLab