remove_invalid: Remove invalid objects from GTFS data

View source: R/filter_gtfs.R

remove_invalidR Documentation

Remove invalid objects from GTFS data

Description

Remove all objects from GTFS data that are not used in all relations that they are required to be. That is, agency-routes relation (agency_id), routes-trips relation (route_id), trips-shapes relation (shape_id), trips-frequencies relation (trip_id), trips-stop_times relation (trip_id), stop_times-stops relation (stop_id), and trips-calendar relation (service_id), recursively, until GTFS data does not reduce its size anymore. For example, if one agency_id belongs to routes but not to agency will be removed. This might cause one cascade removal of objects in other relations that originally did not have any inconsistency.

Usage

remove_invalid(gtfs_data, only_essential = TRUE, prompt_invalid = FALSE)

Arguments

gtfs_data

A list of data.tables read using gtfs2gps::reag_gtfs().

only_essential

Remove only the essential files? The essential files are all but agency, calendar, and routes. Default is TRUE, which means that agency-routes, routes-trips, and trips-calendar relations will not be processed as restrictions to remove objects.

prompt_invalid

Show the invalid objects. Default is FALSE.

Value

A subset of the input GTFS data.

Examples

poa <- read_gtfs(system.file("extdata/poa.zip", package = "gtfs2gps"))
object.size(poa)
subset <- remove_invalid(poa)
object.size(subset)

gtfs2gps documentation built on April 29, 2023, 1:12 a.m.