Skip to contents

Croquis is a transit sketch planning tool. Use it to rapidly create and edit transit networks and schedules in GTFS (General Transit Feed Specification) format. The easiest way to get started, once Croquis is installed, is to launch the Shiny app using croquis().

Using the Croquis app, you can create a new GTFS from scratch or upload an existing one and edit it. Croquis notably grants you the option to toggle trip speeds and headways by hour, as well as speeds across route segments to ensure that the output GTFS reflects real-world variability in service frequency and speed. The Produce a GTFS vignette provides a walkthrough.

GTFS files generated by Croquis can be used to evaluate transit network designs using travel time and accessibility analysis tools like r5r.

In some limited cases, GTFS created with Croquis could be used for deployment onto customer information platforms such as Google Maps and Transit app. Croquis’ GTFS outputs should pass the MobilityData GTFS Schedule Validator without errors or warnings.

Croquis introduces a new data structure that facilitates GTFS creation and editing, called SSFS (Simplified Speed and Frequency Specification). Functions in this package help convert between GTFS and SSFS formats. Read more about the SSFS data format in this vignette.

Croquis also includes a calibration engine, apply_gtfs_speeds_to_ssfs(), which allows you to adjust speeds by hour and by service as well as across route segments for an SSFS based on the scheduled speeds described in a reference GTFS.

Installation

On your machine with R installed, you can install the development version of croquis from GitHub with:

# Install using remotes
# install.packages("remotes")
remotes::install_github("julian-city/croquis")

# Or install using pak
# install.packages("pak")
pak::pak("julian-city/croquis")

Installing croquis will install the sf package and its dependencies, if sf is not already installed. This may take several minutes.

Usage

Croquis app

Once you have installed Croquis, you can launch the app to get started.

croquis::croquis()

Within the Croquis app, you can set the network region, create stops, define routes, create schedules and more in order to set up a viable GTFS. You can also upload an existing GTFS and edit its network and schedule within the Croquis app. When you are done, you can export your project to GTFS .zip format or export it (as a .rds file) in order to import it again later and continue working.

The home panel of the app contains more detailed instructions on how to use it.

Conversion functions

Two functions have been created to handle conversions between GTFS and SSFS formats: gtfs_to_ssfs() and ssfs_to_gtfs(). These are called by the Croquis app to handle imports and exports. You can also use them to view, edit and create SSFS data and GTFS data from SSFS within your programming environment.

For now, gtfs_to_ssfs() requires the input GTFS to contain all required tables of the GTFS file format, plus calendar.

SSFS data structure

Simplified Speed and Frequency Specification (SSFS) was created to facilitate GTFS creation and editing. In short, SSFS is a simplified representation of the information contained in a GTFS. Like GTFS, it is a list of tables (SSFS however contains two sf objects). Some of these tables contain instructions for how to build GTFS stop_times. Others are carried over directly to and from GTFS files.

When you load a GTFS into the app, gtfs_to_ssfs() is used to convert it into SSFS file format. What you are directly editing in the various panels of the Croquis app is the SSFS. When exporting to GTFS, ssfs_to_gtfs() is called.

croquis::ligne_jaune, croquis::stm_metro, croquis::mileend and croquis::ttc_subway are all pre-loaded examples of SSFS data that you can view to better understand the data structure.

Calibration engine

Using a reference GTFS, you can calibrate SSFS speeds by hour and across route segments to reflect real-world conditions using apply_gtfs_speeds_to_ssfs(). This will modify the speeds and speed factors detailed in the ssfs$hsh and ssfs$stop_seq tables of an SSFS.

The experimental function works by creating a temporal-spatial matrix of speeds based on the stop_times and shapes of the reference GTFS. The interstop speed matrix contains spatial data points of average speed for every service, every hour, and every interstop. This data is applied to adjust speeds of the SSFS where possible. OSRM or Valhalla routing is used as a fallback to calculate speeds for segments and times described in the SSFS that are not recorded in the GTFS.

gtfs_to_interstop_matrix() and apply_interstop_matrix_to_ssfs() are functions that, together, accomplish the same thing as apply_gtfs_speeds_to_ssfs(). They are included here for development and demonstration purposes. gtfs_to_interstop_matrix() outputs the interstop matrix that is used to calibrate the ssfs in apply_interstop_matrix_to_ssfs().

Companion functions

Two helpful companion functions have been included for extracting GTFS data pertaining to a subset of routes. These are gtfs_retain_routes() and gtfs_remove_routes(). Both functions output a GTFS that includes or excludes data related to routes supplied to retain_routes or remove_routes arguments.

License

MIT License

Disclaimers

This package is in active development. Use with discretion and validate outputs for quality and accuracy.