filter_area: Filter a Feed by Stop Locations in an Area

View source: R/filter_area.R

filter_areaR Documentation

Filter a Feed by Stop Locations in an Area

Description

Select stops intersecting a polygon or bounding box, retaining either whole trips that serve those stops or only the calls inside the area.

Usage

filter_area(gtfs, area, full_trips = TRUE)

Arguments

gtfs

A GTFS object.

area

An 'sf'/'sfc' polygon with a known CRS, an 'st_bbox', or a numeric WGS84 bounding box ordered xmin, ymin, xmax, ymax.

full_trips

Logical. Retain complete trips (default). If 'FALSE', retain only inside calls; trips with fewer than two remaining calls are removed. Cropped endpoints must have known arrival and departure times.

Details

Selection uses stop points, including polygon boundaries, rather than shape intersection. Cropped trips keep original stop sequences and shapes; distance calculations cover only retained stops. Frequency windows are shifted when cropping changes the first stop. Original times and measures are retained. A crop may connect retained stops across an excluded area; it does not split trips into separate contiguous sections.

Value

A 'wizardgtfs' object with related tables pruned. Parent stations are retained. No matching service returns an empty feed with a warning.

Examples

filter_area(for_rail_gtfs, c(-39, -4, -38, -3))

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