UK2GTFS is an R package to convert and work with train, tram, bus, ferry, and metro timetable data from the unfriendly and difficult to use formats used in the UK to the easy to use GTFS format. The main purpose of developing the package is to support using OpenTripPlanner in the UK.
Example results are published as GitHub releases these come with no guarantee of quality.
The UK has two main sources of public transport timetable data Traveline publishes data on buses and light rail and National Rail publishes data on heavy rail. Each uses a data format that is unique to that organisation and both formats are old and difficult to use. Many countries have adopted the GTFS format which was developed by Google as a simple standard for publishing timetable data. Due to the wide-spread adoption of GTFS many useful tools have been developed that accept GTFS files as inputs. This package is intended to make the conversion of UK data to the GTFS format simple and easy.
Update November 2020
The Open Bus Data Service now offers a national GTFS download option based on ITO World’s TransXchange to GTFS converter. These include bus and light rail but not heavy rail timetables. For non-expert users it will probably be easier to download these files. However this packages is still being maintained to support conversion of historical files, and because the conversion of TransXchange to GTFS is open to interpretation and having alternative converters is useful.
There are a number of pre-existing options for converting data to GTFS. This package aims to go beyond basic conversion by providing a range of additional functionality:
shapes.txt) built by routing services over a map of the UK rail network (atoc2gtfs(shapes = TRUE))gtfs_read(), gtfs_write())gtfs_clean(), gtfs_force_valid(), gtfs_fast_trips())gtfs_compress())gtfs_validate_internal()) - checks required tables and columns, duplicated ids, referential integrity, enum and date/time values, and time/calendar logic across the whole feed including shapes, frequencies, transfers and fare tablesgtfs_clip(), gtfs_trim_dates(), gtfs_split()) and merging (gtfs_merge()) - subsetting keeps the optional tables (shapes, frequencies, transfers, fares) consistent with the subset feedgtfs_stop_frequency(), gtfs_trips_per_zone()), including frequency-based services (frequencies.txt)Install the package with remotes as follows:
install.packages("remotes") # If you do not already have the remotes package
remotes::install_github("ITSleeds/UK2GTFS")
library(UK2GTFS)You can find full documentation for the package, including a list of functions and more detail on converting TransXchange and ATOC CIF.
This package is a work in progress and comes with no guarantees. It can convert train, bus, tram, metro and ferry timetables to GTFS, add fares (rail and bus) and rail route shapes, and provides a toolkit for cleaning, validating, subsetting and analysing GTFS feeds. See NEWS.md for recent changes. Conversion occasionally fails on specific files.
Please report failed conversions as GitHub Issues