Filters a GTFS object by route_types, keeping (or dropping) the relevant entries in each file.

filter_by_route_type(gtfs, route_type, keep = TRUE)

Arguments

gtfs

A GTFS object, as created by read_gtfs().

route_type

An integer vector. The route_types used to filter the data.

keep

A logical. Whether the entries related to the specified route_types should be kept or dropped (defaults to TRUE, which keeps the entries).

Value

The GTFS object passed to the gtfs parameter, after the filtering process.

Route types

Valid options are:

  • 0 - Tram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.

  • 1 - Subway, Metro. Any underground rail system within a metropolitan area.

  • 2 - Rail. Used for intercity or long-distance travel.

  • 3 - Bus. Used for short- and long-distance bus routes.

  • 4 - Ferry. Used for short- and long-distance boat service.

  • 5 - Cable tram. Used for street-level rail cars where the cable runs beneath the vehicle, e.g., cable car in San Francisco.

  • 6 - Aerial lift, suspended cable car (e.g., gondola lift, aerial tramway). Cable transport where cabins, cars, gondolas or open chairs are suspended by means of one or more cables.

  • 7 - Funicular. Any rail system designed for steep inclines.

  • 11 - Trolleybus. Electric buses that draw power from overhead wires using poles.

  • 12 - Monorail. Railway in which the track consists of a single rail or a beam.

Examples

# read gtfs
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)

object.size(gtfs)
#> 811304 bytes

# keeps entries related to passed route_types
smaller_gtfs <- filter_by_route_type(gtfs, route_type = 1)
object.size(smaller_gtfs)
#> 180920 bytes

# drops entries related to passed route_types
smaller_gtfs <- filter_by_route_type(gtfs, route_type = 1, keep = FALSE)
object.size(smaller_gtfs)
#> 654360 bytes