OpenTripPlanner for R

Travis build status codecov AppVeyor Build Status Project Status: Active – The project has reached a stable, usable state and is being actively developed. DOI status CRAN_Status_Badge

opentripplanner is an R package that provides a simple yet flexible interface to OpenTripPlanner (OTP). OTP is a multimodal trip planning service written in Java. For more information on what OTP is, see the prerequisites vignette.

opentripplanner can be used to interface with a remote instance of OTP (e.g. a website) or help you set up and manage a local version of OTP for private use. Basic setup and routing functions are outlined in the getting started vignette, while advanced functionality such as batch routing, isochrones, and customised setup is described in the advanced features vignette.



To use OpenTripPlanner on your local computer you will need to install Java 8 and download the latest version of OTP. Instructions on installing Java and setting up OTP can be found in the prerequisites vignette.

R Package

To install the stable CRAN version:

install.packages("opentripplanner") # Install Package
library(opentripplanner)            # Load Package

Install the development version using devtools:

# If you do not already have the devtools package
# Install the package from GitHub
# Load the package


The package contains three groups of functions:

Functions for setting up a local instance of OTP:

  1. otp_dl_jar() To download the OTP Jar file;
  2. otp_dl_demo() To download the demo data for the Isle of Wight;
  3. otp_build_graph() To make a OTP graph from raw data;
  4. otp_setup() To start up a local instance of OTP;
  5. otp_make_config() To make a config object;
  6. otp_validate_config() To validate a config object;
  7. otp_write_config() To save a config object as a json file.

Functions for connecting to a local or remote instance of OTP:

  1. otp_connect() To connect to OTP.

Functions for retrieving data from OTP:

  1. otp_plan() To get routes from A to B;
  2. otp_isochrone() To get isochrone maps;
  3. otp_geocode() To get the locations of named places e.g. road names.

Results are returned as sf objects.


As this package does not work without a working connection to OTP, tests only run on machines that have the environment variable I_have_OTP with the value TRUE. You can add this with usethis::edit_r_environ().



This package was built off the tutorial by Marcus Young.


Please note that the opentripplanner project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms. Bug reports and comments are welcome as Github Issues and code submissions as Pull Requests.


Please cite the JOSS paper in publications:

Morgan et al., (2019). OpenTripPlanner for R. Journal of Open Source Software, 4(44), 1926,