get_distances: Calculate Consistent Trip and Segment Distances

View source: R/get_distances.R

get_distancesR Documentation

Calculate Consistent Trip and Segment Distances

Description

Calculate distances in metres using the same segments for every summary.

Usage

get_distances(
  gtfs,
  method = "by_trip",
  trips = "all",
  distance_method = c("shapes", "straight")
)

Arguments

gtfs

A GTFS object.

method

One of '"by_trip"', '"by_route"', or '"detailed"'.

trips

Character trip IDs or '"all"'.

distance_method

Either '"shapes"' (default) or '"straight"'.

Details

Shape distances use stop and shape 'shape_dist_traveled' values together when available, converting their common units to metres using the shape geometry. Otherwise stops are projected onto shape segments in sequence order. This is an approximation, especially on loops; supplied distance measures are preferred. Missing shapes fall back to straight geodesic segments with a warning. Trip lengths cover only served segments, rather than the complete shared shape. Straight distances are geodesic.

Value

A tibble. Detailed rows identify trips and their originating 'stop_sequence'; trip and route summaries retain service patterns.

Examples

get_distances(for_rail_gtfs, "by_trip")

GTFSwizard documentation built on Nov. 18, 2026, 1:07 a.m.