split_trip | R Documentation |
'split_trip' divides a specified trip in a 'wizardgtfs' object into multiple sub-trips by updating the stop sequences, trip identifiers, and related data, allowing for analysis or adjustments to different segments of the original trip.
split_trip(gtfs, trip, split = 1)
gtfs |
A GTFS object, ideally of class 'wizardgtfs'. If not, it will be converted. |
trip |
A character vector specifying the 'trip_id' to be split. |
split |
An integer indicating the number of splits to apply. One split means two trip segments. |
- The function creates sub-trips by dividing the specified trip(s) into equal parts based on the stop sequence.
- New trip IDs are generated for each sub-trip, and 'stop_times', 'trips', 'frequencies', and 'transfers' tables are updated accordingly.
- If 'shape_dist_traveled' is present, it is adjusted to reflect distances within each new sub-trip.
- After the split, the function re-generates the shapes table for the new trips using 'get_shapes', and merges it back into the 'wizardgtfs' object.
- Be aware: 'get_shapes' reconstructs shapes using euclidean approximation and may not be accurate.
- The maximum number of sections in a given trip is restricted by its amount of stops
A GTFS object with the specified trip split into new sub-trips.
'split_trip()' uses stop sequences to recriate the shapes table of split trips; accordingly, it should not be used after 'filter_time()', as this function removes invalid 'stop_times'.
[GTFSwizard::get_shapes()], [GTFSwizard::merge_gtfs()]
# Split a trip into 3 segments
gtfs_split <- split_trip(for_rail_gtfs, trip = for_rail_gtfs$trips$trip_id[1:3], split = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.