trread (gtfs reader)

Tom Buckley

2018-07-22

Description

tread is a package for reading the GTFS data standard into R. It can read directly from URL’s or flat files, and does some validation of the data structure against the specification.

Goal

This is a highly simplified fork/piece of the gtfsr package.

The goal is to break that package into parts to simplify maintenance.

Contributors

Among the many contributors, Danton Noriega wrote much of this package.

Usage

Fetch data for a bus system in Accra, Ghana from a URL.

library(trread)
library(dplyr)

accra_gtfs <- import_gtfs("https://github.com/AFDLab4Dev/AccraMobility/raw/master/GTFS/GTFS_Accra.zip")

Count and list the number of stops per route.

attach(accra_gtfs)

routes_df %>% inner_join(trips_df, by="route_id") %>%
  inner_join(stop_times_df) %>% 
    inner_join(stops_df, by="stop_id") %>% 
      group_by(route_long_name) %>%
        summarise(stop_count=n_distinct(stop_id)) %>%
  arrange(desc(stop_count))