get_corridor: Identify and Extract Transit Corridors

View source: R/get_corridor.R

get_corridorR Documentation

Identify and Extract Transit Corridors

Description

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.

Usage

get_corridor(gtfs, i = 0.01, min.length = 1500)

Arguments

gtfs

A GTFS object, preferably of class 'wizardgtfs'. If not, the function will attempt to convert it using 'GTFSwizard::as_wizardgtfs()'.

i

A numeric value representing the percentile threshold for selecting high-density segments. Defaults to '0.01' (top 1% of segments by trip frequency).

min.length

A numeric value specifying the minimum corridor length (in meters) to retain. Defaults to '1500'.

Details

The function performs the following steps:

  1. Filters and orders 'stop_times' data to identify consecutive stops ('stop_from' and 'stop_to') for each trip.

  2. Counts the number of trips between each stop pair and selects the top 'i' percentile of segments by trip frequency.

  3. Groups spatially connected segments into corridors using graph theory and adjacency matrices.

  4. Filters corridors by the minimum length ('min.length').

  5. Returns the resulting corridors with their metadata and geometry.

Value

An 'sf' object containing the following columns:

corridor

A unique identifier for each corridor, prefixed with "corridor-".

stops

A list of stop IDs included in each corridor.

trip_id

A list of trip IDs included in each corridor.

length

The total length of the corridor, in meters.

geometry

The spatial representation of the corridor as an 'sf' linestring object.

Note

The function uses 'sf' and 'igraph' for spatial and graph-based computations. Ensure the 'gtfs' object includes 'stop_times' table.

See Also

[GTFSwizard::as_wizardgtfs()]

Examples

corridors <- get_corridor(for_bus_gtfs, i = 0.02, min.length = 2000)


GTFSwizard documentation built on April 4, 2025, 4:10 a.m.