Skip to contents

Write GTFS stored in memory as a list of data.tables into a zipped GTFS feed, using write_gtfs. By default an existing zip file is overwritten; set overwrite = FALSE to raise an error instead.

Usage

write_gtfs(
  gtfs,
  zipfile,
  overwrite = TRUE,
  quiet = FALSE,
  compression_level = 6
)

Arguments

gtfs

A GTFS data set stored in memory as a list of data.tables/data.frames.

zipfile

The pathname of a .zip file to be saved with the GTFS data.

overwrite

A logical. Whether to overwrite an existing .zip file. If FALSE and zipfile already exists, an error is raised. Defaults to TRUE.

quiet

A logical. Whether to hide log messages and progress bars. Defaults to FALSE.

compression_level

A whole number from 1 (fastest) to 9 (smallest file). The compression level of the zip file. Defaults to 6.

Value

The GTFS data, invisibly.

Examples


# read a gtfs.zip to memory
poa <- read_gtfs(system.file("extdata/poa.zip", package = "gtfs2gps")) |>
  gtfstools::filter_by_shape_id("T2-1") |>
  filter_single_trip()
#> Unzipped the following files to /tmp/RtmpL1LF2I/gtfsio:
#>   * agency.txt
#>   * calendar.txt
#>   * routes.txt
#>   * shapes.txt
#>   * stop_times.txt
#>   * stops.txt
#>   * trips.txt
#> Reading agency
#> Reading calendar
#> Reading routes
#> Reading shapes
#> Reading stop_times
#> Reading stops
#> Reading trips

# write GTFS data into a zip file
write_gtfs(poa, paste0(tempdir(), "/mypoa.zip"))
#> Writing text files to /tmp/RtmpL1LF2I/gtfsio1dea176204d1
#>   - Writing agency.txt
#>   - Writing calendar.txt
#>   - Writing routes.txt
#>   - Writing shapes.txt
#>   - Writing stop_times.txt
#>   - Writing stops.txt
#>   - Writing trips.txt
#> GTFS object successfully zipped to /tmp/RtmpL1LF2I/mypoa.zip