Filters a GTFS object by shape_id
s, keeping (or dropping) the relevant
entries in each file.
Arguments
- gtfs
A GTFS object, as created by
read_gtfs()
.- shape_id
A character vector. The
shape_id
s used to filter the data.- keep
A logical. Whether the entries related to the specified
shape_id
s should be kept or dropped (defaults toTRUE
, which keeps the entries).
See also
Other filtering functions:
filter_by_agency_id()
,
filter_by_route_id()
,
filter_by_route_type()
,
filter_by_service_id()
,
filter_by_sf()
,
filter_by_spatial_extent()
,
filter_by_stop_id()
,
filter_by_time_of_day()
,
filter_by_trip_id()
,
filter_by_weekday()
Examples
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
shape_ids <- c("17846", "68962")
object.size(gtfs)
#> 811304 bytes
# keeps entries related to passed shape_ids
smaller_gtfs <- filter_by_shape_id(gtfs, shape_ids)
object.size(smaller_gtfs)
#> 99456 bytes
# drops entries related to passed shape_ids
smaller_gtfs <- filter_by_shape_id(gtfs, shape_ids, keep = FALSE)
object.size(smaller_gtfs)
#> 740840 bytes