Giter VIP home page Giter VIP logo

otp-travel-time-matrix's Introduction

Tutorial with reproducible example to estimate a travel time matrix using OpenTripPlanner and Python

This repository aims to provide a reproducible example of how to build an Origin-Destination travel time matrix using OpenTripPlanner (OTP) and Python. The Python scripts presented here can still be improved and it would be great to have your contributions, specially if you have ideas on how to improve the speed/efficiency of the code, or include a progress bar etc !

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 your points of interest (trip origins and destinations)
  • A Python script

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

This repository should help you build a travel time matrix in 4 simple steps

Step 1: Install Jython 2.7 in your computer

Here you find the executable jar for installing Jython

Step 2: Download files to your folder

Most of the files you need are in this repository already. The other files you can download from here:

Step 3: Build Graph.obj

Open your Command Prompt and run this line to set the directory where you've saved the files

cd path/to/otp-travel-time-matrix

Now run this line to build the Graph.obj. Once OTP has built the Graph.obj, move it to the subdirectory portland.

java -Xmx4G -jar otp-1.3.0-shaded.jar --cache . --basePath . --build .

Step 4: Run the Python script

Three options here:

4.1 A simple script like python_script.py will return a travel time matrix for one single deaprture time (e.g. at 10:00:00 on 15-November-2015)

c:\jython2.7.0\bin\jython.exe -J-XX:-UseGCOverheadLimit -J-Xmx10G -Dpython.path=otp-1.3.0-shaded.jar python_script.py

4.2 The second option is to use a script like python_script_loopHM.py, which will create a different travel time matrix departing every ten minutes, say between 10am and 6pm, and save each matix in a separete .csv file

c:\jython2.7.0\bin\jython.exe -J-XX:-UseGCOverheadLimit -J-Xmx10G -Dpython.path=otp-1.3.0-shaded.jar python_script_loopHM.py

4.3 The third option uses the python script named python_script_loopHM_parallel.py, and it allows one to estimate various travel time matrices for different departure times (similarly to the second option) but using parallel computing. This makes things much faster because each computer processor will compute the travel-time matrix of a different departure time in parallel.

c:\jython2.7.0\bin\jython.exe -J-XX:-UseGCOverheadLimit -J-Xmx10G -Dpython.path=otp-1.3.0-shaded.jar python_script_loopHM_parallel.py

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. The two python scripts that use multiple threads to run in parallel were developed in collaboration with Nate Wessel and Jader Martins. Nate and Jader did most of the heavy lifting, really.

More information about how to automate OTP here.

Citation

If you have used this script in your work and you would like to cite it, you can use the following reference: DOI

Pereira, R. H. M. (2019). Tutorial with reproducible example to estimate a travel time matrix
using OpenTripPlanner and Python. Retrieved from https://github.com/rafapereirabr/otp-travel-time-matrix. 
doi:10.5281/zenodo.3242134

otp-travel-time-matrix's People

Contributors

rafapereirabr avatar jleapemit avatar laurentg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.