Learn R Programming

GTFSwizard (version 1.1.0)

get_hubs: Identify Transit Hubs

Description

The `get_hubs` function identifies transit hubs from a GTFS dataset by calculating the number of trips and unique routes served by each stop. It returns a spatial object with metadata for each hub, allowing for further analysis or visualization.

Usage

get_hubs(gtfs)

Value

An `sf` object containing the following columns:

stop_id

The unique identifier for each stop.

trip_id

A list of trip IDs associated with the stop.

route_id

A list of unique route IDs associated with the stop.

n_trip

The total number of trips that pass through the stop.

n_routes

The total number of unique routes that pass through the stop.

geometry

The spatial location of the stop as an `sf` point object.

Arguments

gtfs

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

Details

The function performs the following steps:

  1. Extracts `stop_id` and `trip_id` pairs from the `stop_times` table.

  2. Joins this data with the `trips` table to associate `route_id` with each trip.

  3. Groups by `stop_id` to compute the number of trips (`n_trip`) and unique routes (`n_route`) per stop.

  4. Joins the resulting data with the spatial geometry of stops, transforming it into an `sf` object.

  5. Sorts the hubs by the number of unique routes (`n_routes`) in descending order.

See Also

[GTFSwizard::get_stops_sf()], [GTFSwizard::as_wizardgtfs()]

Examples

Run this code
# Identify hubs in a GTFS dataset
get_hubs(for_rail_gtfs)

Run the code above in your browser using DataLab