get_hubs | R Documentation |
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.
get_hubs(gtfs)
gtfs |
A GTFS object, preferably of class 'wizardgtfs'. If not, the function will attempt to convert it using 'GTFSwizard::as_wizardgtfs()'. |
The function performs the following steps:
Extracts 'stop_id' and 'trip_id' pairs from the 'stop_times' table.
Joins this data with the 'trips' table to associate 'route_id' with each trip.
Groups by 'stop_id' to compute the number of trips ('n_trip') and unique routes ('n_route') per stop.
Joins the resulting data with the spatial geometry of stops, transforming it into an 'sf' object.
Sorts the hubs by the number of unique routes ('n_routes') in descending order.
An 'sf' object containing the following columns:
The unique identifier for each stop.
A list of trip IDs associated with the stop.
A list of unique route IDs associated with the stop.
The total number of trips that pass through the stop.
The total number of unique routes that pass through the stop.
The spatial location of the stop as an 'sf' point object.
The function uses 'sf' for spatial data manipulation. Ensure that the GTFS dataset includes the 'stop_times', 'trips', and 'stops' tables.
[GTFSwizard::get_stops_sf()], [GTFSwizard::as_wizardgtfs()]
# Identify hubs in a GTFS dataset
get_hubs(for_rail_gtfs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.