
Get aggregated frequency per hour for each OSM way
Source:R/get_way_frequency_hourly.R
get_way_frequency_hourly.RdFor each OSM way with GTFS service, returns the number of departures aggregated per hour and direction.
Usage
get_way_frequency_hourly(
gtfs,
q,
date = GTFShift::calendar_nextBusinessWednesday(),
keep_osm_attributes = FALSE
)Arguments
- gtfs
tidygtfs. GTFS feed.
- q
osmdata::opq. Overpass query for transit network, to obtain OSM route ways, using
GTFShift::osm_shapes_to_routes().- date
Date (Default
GTFShift::calendar_nextBusinessWednesday()). Reference date to consider when analyzing the GTFS file.- keep_osm_attributes
Boolean (Default FALSE). Whether to keep all OSM way attributes in the output
sfobject.
Value
An sf data.frame object with the following columns:
way_osm_id, theosm_idattribute from OSM way.hour, the hour for which the frequency applies (24 hour format).frequency, the number of services for the route that depart from the first stop for the corresponding 60 minutes period.routes, the list of route_ids that use the way, separated by semicolon.geometry, the route shape.(if
keep_osm_attributes = TRUE) all OSM way attributes.
Details
This method analyses the GTFS feed for a representative day, finding for each route the corresponding OSM ways using GTFShift::osm_shapes_to_routes()
(routes not on OSM are ignored), aggregating the number of services per hour and direction for each.
For a detailed example, see the vignette("analyse").
Examples
if (FALSE) { # \dontrun{
gtfs = GTFShift::load_feed("gtfs.zip")
q = opq(bbox=sf::st_bbox(tidytransit::shapes_as_sf(gtfs$shapes))) |> add_osm_feature(key = "route", value = "bus")
frequency_analysis = GTFShift::get_way_frequency_hourly(gtfs, q)
} # }