Service analysis and visualization

knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(GTFSwizard)
gtfs <- for_rail_gtfs

GTFSwizard analyzes scheduled service. Results describe the timetable rather than observed vehicle movements or passenger demand. Pay attention to each function's aggregation method because it defines the observational unit.

Service patterns

A GTFS service_id identifies one service calendar. Several IDs can operate on the same date. GTFSwizard assigns the same service_pattern to dates that have the exact same set of active services. Consequently, one service_id can belong to several patterns when the services operating alongside it change.

get_servicepattern(gtfs)

pattern_frequency is the number of dates represented by that exact active service set. The most frequent active pattern is therefore a useful default typical day, but it is not necessarily a weekday and should be interpreted from the feed calendar.

plot_calendar(gtfs, fill = "service_pattern", facet_by_year = TRUE)

Frequency and headway

Frequency counts scheduled departures. Headway measures elapsed minutes between successive service instances in a comparable group. Route-level results retain direction_id when it is available.

head(get_frequency(gtfs, method = "by_route"))
head(get_headways(gtfs, method = "by_route"))

Common method names use underscores:

Check a function's help page because not every method is meaningful for every indicator.

plot_frequency(gtfs)
plot_headways(gtfs)

Duration, distance, speed, dwell time, and fleet

Duration and distance are schedule and geometry properties. Speed combines them, dwell time is departure minus arrival at a stop call, and fleet counts simultaneously active scheduled trip instances.

head(get_durations(gtfs, method = "by_trip"))
head(get_distances(gtfs, method = "by_trip"))
head(get_speeds(gtfs, method = "by_route"))
head(get_dwelltimes(gtfs, method = "by_route"))
get_fleet(gtfs, method = "peak")

These are scheduled indicators. They do not estimate congestion, reliability, vehicle availability, layover policy, deadheading, or passenger loads unless those effects are already represented in the feed.

Spatial structure

The spatial helpers return standard sf objects. Inferred shapes and corridor segments connect coordinates with straight lines; they are not map-matched paths.

stops <- get_stops_sf(gtfs$stops)
shapes <- get_shapes_sf(gtfs$shapes)
nrow(stops)
nrow(shapes)

Hubs summarize stops by their scheduled trip and route connections. Corridors join frequently served consecutive stop pairs and report length in meters.

head(get_hubs(gtfs))
get_corridor(gtfs, i = 0.2, min_length = 100)

Use plot_hubs() and plot_corridor() for the corresponding network views. The i argument is a share threshold, not an absolute number of trips.

Choosing a plot

All plotting functions return ggplot objects, so labels and themes can be extended with ggplot2 when needed.



Try the GTFSwizard package in your browser

Any scripts or data that you put into this service are public.

GTFSwizard documentation built on Aug. 21, 2026, 5:16 p.m.