get_shapes | R Documentation |
The 'get_shapes' function reconstructs the 'shapes' table for a GTFS dataset using an approximation based on stop coordinates and sequence information. It creates geometric representations of trips by connecting stops in sequence for each trip.
get_shapes(gtfs)
gtfs |
A GTFS object, ideally of class 'wizardgtfs'. If not, it will be converted automatically. |
This function constructs the 'shapes' table by sequentially connecting stops along each trip using a Euclidean approximation. If the GTFS object already contains a 'shapes' table, it will be overwritten, and a warning will be displayed. The process involves:
- Selecting and arranging stops by trip and sequence
- Connecting stops with line segments to form a path for each trip
- Grouping unique paths into distinct shape IDs
A modified GTFS object that includes a 'shapes' table derived from the stops and trips information.
This approximation may not perfectly represent real-world shapes, especially for complex or curved routes. 'get_shapes()' uses stop sequences to recriate the shapes table; accordingly, it should not be used after 'filter_time()', as this function removes invalid 'stop_times'.
[GTFSwizard::as_wizardgtfs()], [GTFSwizard::get_shapes_df()]
# Generate a shapes table for a GTFS object
gtfs_with_shapes <- get_shapes(gtfs = for_rail_gtfs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.