Skip to contents

Get OSM routes that match shapes, based on geometrical match

Usage

osm_shapes_match_routes(
  gtfs,
  q,
  geometry = TRUE,
  gtfs_match = "route_short_name",
  osm_match = "ref"
)

Arguments

gtfs

tidygtfs. GTFS feed.

q

osmdata::opq. Overpass query for transit network

geometry

Boolean (Default TRUE). If TRUE, returns sf object with geometry, otherwise, a simple data.frame.

gtfs_match

String (Default route_short_name). routes.txt attribute that identifies routes. Accepted values: route_id, route_short_name, route_long_name.

osm_match

String (Default ref). OSM attribute that identifies routes by matching with gtfs_match. Accepted values: ref, name, gtfs:route_id.

Value

Details

For each route, matches its trips' shapes with OSM route relations.

The match is performed considering, for each shape, the closest OSM route, based on the start and end points, total length and number of stops.

Examples

if (FALSE) { # \dontrun{
gtfs <- GTFShift::load_feed("gtfs.zip")

q = opq("Lisbon")  |>
  add_osm_feature(key = "route", value = c("bus", "tram")) |>
  add_osm_feature(key = "network", value = "Carris", key_exact = TRUE)

shapes_match_routes = GTFShift::osm_shapes_match_routes(gtfs, q)
} # }