Skip to content

GTFS data segmentation using R #219

Answered by polettif
subha-nair asked this question in Q&A
Discussion options

You must be logged in to vote

In the spirit of advent of code I couldn't help but tinker with this a bit more 🎄🎅 🎁

The following code matches nearby shape points and finds overlapping shapes along segments. It looks ok but I didn't inspect the plausibility of the example dataset further and there might be pitfalls with other dataset. So it's not a catch-all workflow but it should provide a starting point.

Snap nearby shape coordinates to allow matching

library(dplyr)
library(sf)
library(tidytransit)

# Add interpolated points along shape lines
add_shape_points = function(gtfs_shapes, crs, max_segment_dist) {
    gtfs_shapes |>
        shapes_as_sf(crs) |>
        st_segmentize(max_segment_dist) |>
        tidytransit:::

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@idshklein
Comment options

@polettif
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by polettif
Comment options

You must be logged in to vote
3 replies
@polettif
Comment options

@mpadge
Comment options

@polettif
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants