My new R package 'otpr' is now available on CRAN. It's a wrapper for the OpenTripPlanner (OTP) API and is based on a set of functions I originally wrote to generate variables for the station choice and trip end models I calibrated during my PhD research. The package is primarily aimed at researchers and transport planners who want to carry out accessibility studies or generate variables for transport models.
The package consists of four main functions:
Defines and tests the connection to an OTP instance.
Gets the distance in metres between an origin and destination on the street and/or path network by specified mode. Valid modes are car, bicycle or walk.
In its simplest use case this function gets the journey time between an origin and destination by specified mode(s). Valid modes are car, bicycle, walk, transit (all available public transport modes), bus, and rail. For convenience all the public transport modes allow walk by default. There is also the option of combining transit and bicycle.
This function can also return more detailed information, breaking down the journey by transit time, walking time, waiting time and the number of transfers.
This function returns one or more travel time isochrones for a location. These are returned in GeoJSON format. These can be generated either from or to the specified location. This function is only available for transit or walk modes (which is a limitation of OTP).
The package currently supports a subset of the parameters that are available for the OTP 'planner' and 'isochrone' API resources. This is based on my experience of using OTP to generate this type of data and to keep the functions relatively simple from the user perspective. For this first release I have included the following:
For a future release I will be allowing a larger range of parameters to be optionally passed through to the API query, giving greater flexibility but still keeping the external functions simple for users who don't need such detailed control.
For more information, including code examples, take a look at the GitHub repository for the package. I'd welcome any feedback as well as suggestions for future development.