This repository aims to provide a reproducible example of how to build an Origin-Destination matrix using OpenTripPlanner (OTP). The Python script still can be improved, for example to increase speed/efficiency of the code. Contributions are welcomed !
Input
- An Open Street Map of the region in
.pbf
format - GTFS dataset
- The OTP java application
.jar
file - Jython standalone application
.jar
file - A
.csv
file with long lat of the points i
Output
- A
.csv
file with the travel time between pairs of points. It looks something like this:
GEOID GEOID travel_time
1 1 60
1 2 861
1 3 2234
2 1 861
2 2 42
2 3 3032
3 1 2235
3 2 3040
3 3 92
Here you find the executable jar for installing Jython
Most of the files you need are in this repository alredy. The other files you can download from here:
Open your Command Prompt and run this line to set the directory where you've saved the files
cd C:\Users\rafa\Desktop\otp-travel-time-matrix
Now run this line to build the Graph.obj
java –Xmx10G -jar otp-0.19.0-SNAPSHOT-shaded.jar --cache C:\Users\rafa\Desktop\otp-travel-time-matrix --basePath C:\Users\rafa\Desktop\otp-travel-time-matrix --build C:\Users\rafa\Desktop\otp-travel-time-matrix
c:\jython2.7.0\bin\jython.exe -J-XX:-UseGCOverheadLimit -J-Xmx10G -Dpython.path=otp-0.19.0-SNAPSHOT-shaded.jar test.py
-
Go to http://abcl.org, download the binary distribution and put it somewhere you can get to it.
-
Then go to https://www.quicklisp.org and download "quicklisp.lisp".
-
Get quicklisp:
java -jar abcl-bin-1.3.3/abcl.jar --load ~/quicklisp.lisp --eval '(quicklisp-quickstart:install)' --eval '(quit)'
As in the python version, except the Jython jar file is unnecessary.
As in the pyhon version
java -d64 -XX:MaxPermSize=1g -XX:+CMSClassUnloadingEnabled -Xmx10G -XX:-UseGCOverheadLimit -Djava.library.path=. -cp otp-0.19.0-SNAPSHOT-shaded.jar:abcl-bin-1.3.3/abcl.jar org.armedbear.lisp.Main --load ~/quicklisp/setup.lisp --load test.lisp --eval '(quit)'
This code is inspired by @laurentg's code but it tries to achieve a different output, providing a travel time matrix. @laurentg has also made important contributions to this repository, to which I am grateful.
More information about how to automate OTP here.