CRAN status gtfsio status badge B status Codecov test coverage Lifecycle: maturing CRAN/METACRAN Total downloads DOI

gtfsio offers tools for the development of GTFS-related packages. It establishes a standard for representing GTFS feeds using R data types based on Google’s Static GTFS Reference. It provides fast and flexible functions to read and write GTFS feeds while sticking to this standard. It defines a basic gtfs class which is meant to be extended by packages that depend on it. And it also offers utility functions that support checking the structure of GTFS objects.


Stable version:


Development version:

install.packages("gtfsio", repos = "")

# or
# install.packages("remotes")


GTFS feeds are read using the import_gtfs() function:


path <- system.file("extdata/", package = "gtfsio")

gtfs <- import_gtfs(path)

#>  [1] "calendar_dates"  "fare_attributes" "fare_rules"      "feed_info"      
#>  [5] "frequencies"     "levels"          "pathways"        "routes"         
#>  [9] "shapes"          "stop_times"      "stops"           "transfers"      
#> [13] "translations"    "trips"           "agency"          "attributions"   
#> [17] "calendar"

import_gtfs() returns a gtfs object. The gtfs class might be extended by other packages using the constructor, validator and methods provided by gtfsio:

#> [1] "gtfs" "list"

Use the export_gtfs() function to write GTFS objects to disk:

tmpf <- tempfile(fileext = ".zip")

export_gtfs(gtfs, tmpf)

#>  [1] "calendar_dates.txt"  "fare_attributes.txt" "fare_rules.txt"     
#>  [4] "feed_info.txt"       "frequencies.txt"     "levels.txt"         
#>  [7] "pathways.txt"        "routes.txt"          "shapes.txt"         
#> [10] "stop_times.txt"      "stops.txt"           "transfers.txt"      
#> [13] "translations.txt"    "trips.txt"           "agency.txt"         
#> [16] "attributions.txt"    "calendar.txt"

For a more complete demonstration please read the introductory vignette.


#> To cite gtfsio in publications use:
#>   Daniel Herszenhut, Flavio Poletti & Mark Padgham. (2021, November).
#>   gtfsio: Read and Write General Transit Feed Specification (GTFS)
#>   Files (Version v1.0.0). Zenodo.
#> A BibTeX entry for LaTeX users is
#>   @Manual{,
#>     title = {gtfsio: Read and Write General Transit Feed Specification (GTFS) Files},
#>     author = {Daniel Herszenhut and Flavio Poletti and Mark Padgham},
#>     month = {nov},
#>     year = {2021},
#>     publisher = {Zenodo},
#>     version = {v1.0.0},
#>     doi = {10.5281/zenodo.5650829},
#>     url = {},
#>   }