G R A P H I T E
graphite [origin: german] noun Definitions:
- a very common mineral, soft native carbon, occurring in black to dark-gray foliated masses, with metallic luster and greasy feel: used for pencil leads, as a lubricant, and for making crucibles and other refractories; plumbago; black lead;
- to write, draw
- Software Prerequisites
- GTFS feed
- Creating and running an OpenTripPlanner server
- For GTFS building (optional)
- A C# compiler such as Visual Studio Code, AND
- For OTP server (required)
An OpenTripPlanner server can be built without a General Transit Feed Specification (GTFS) dataset. However, a GTFS feed is required to analyse public transport. Without it you can analyse car, bicycle, and foot transport using OpenStreetMap (OSM) data.
Sample GTFS data
- buses in Cardiff, Wales, UK. Download (1.7MB)
- buses in Wales, UK. Download (22.3MB)
- buses in Scotland, UK. Download (34.6MB)
- buses in East Anglia, England, UK. Download (3.5MB)
- buses in East Midlands, England, UK. Download (28.0MB)
- buses in Greater London, England, UK. Download (99.8MB)
- buses in the North East, England, UK. Download (43.4MB)
- buses in the North West, England, UK. Download (34.1MB)
- buses in the South East, England, UK. Download (55.3MB)
- buses in the South West, England, UK. Download (26.7MB)
- buses in the West Midlands, England, UK. Download (25.5MB)
- buses in Yorkshire, England, UK. Download (29.2MB)
- national coaches in the UK. Download (1.2MB)
- trains in the UK. Download (21.4MB)
The Data Science Campus has also created a bespoke OpenStreetMap (osm) file for Cardiff, Wales, UK for March 2019:
- Cardiff OSM file. Download (101.1MB)
OSM files for all other regions can be downloaded from geofabrik.
Note: these GTFS do not contain the most recent timetables, it is only designed as a practice set of GTFS data for use with the propeR tool. Some (but not most) services have end dates of 2018-08-15, 2018-09-02, 2018-10-31. Therefore, analysing journeys after these dates will not include these services. Most services have an end date capped at 2020-01-01.
Creating and running an OpenTripPlanner server
OpenTripPlanner (OTP) is an open source multi-modal trip planner, which runs on Linux, Mac, Windows, or potentially any platform with a JVM. More details, including basic tutorials can be found here. Guidance on how to setup the OpenTripPlanner locally can be found here. Here is the method that worked for us:
Check you have the latest java SE runtime installed on your computer, preferrably the 64-bit version on a 64-bit computer. The reason for this is that the graph building process in step 7 uses a lot of memory. The 32-bit version of java might not allow a sufficient heap size to be allocated to graph and server building. For the GTFS sample data [here](add link), a 32-bit machine may suffice.
Create an 'otp' folder in a preferred root directory.
Download the latest single stand-alone runnable .jar file of OpenTripPlanner here. Choose the '-shaded.jar' file. Place this in the 'otp' folder.
Create a 'graphs' folder in the 'otp' folder.
Create a 'default' folder in the 'graphs' folder.
Put the GTFS ZIP folder(s) in the 'default' folder along with the latest OpenStreetMap .osm data for your area, found here. If you're using the sample GTFS data, an .osm file for Cardiff can be found here.
Build the graph by using the following command line/terminal command whilst in the 'otp' folder:
java -Xmx4G -jar otp-1.3.0-shaded.jar --build graphs/default
changing the shaded.jar file name and end folder name to be the appropriate names for your build. '-Xmx4G' specifies a maximum heap size of 4G memory, graph building may not work with less memory than this.
Once the graph has been build you should have a 'Graphs.obj' file in the 'graphs/default' folder. Now initiate the server using the following command from the 'otp' folder:
java -Xmx4G -jar otp-1.3.0-shaded.jar --graphs graphs --router default --server
Again, checking the shaded.jar file and folder names are correct.
- If successful, the front-end of OTP should be accessible from your browser using http://localhost:8080/.
For convenience we have created several docker images to run an OTP server for several regions in the UK. First you must install Docker. To run, type in the command line (parse
-d flag to daemonise):
docker run -p 8080:8080 datasciencecampus/dsc_otp:<tag_number>
1.0(docker image for Cardiff, Wales, UK from March 2019, 298MB)
wales_mar19(docker image for Wales, UK from March 2019, 661MB)
scotland_mar19(docker image for Scotland, UK from March 2019, 1010MB)
england_mar19(docker image for England, UK from March 2019, 1250MB)
If successful, the front-end of OTP should be accessible from your browser using http://localhost:8080/.
Killing a Docker container
To kill a docker container first list all containers running using:
docker stop <container_ID>
Building your own Docker container
A stand-alone OTP server can also be built and deployed in the docker/ directory by editing the
build.sh files, then cd to the docker folder containing the a
Dockerfile and use the command line:
docker build . -t <tag_name>
Dockerfile has the following arguments that can be passed to
docker build using
- HEAP (the heap size of the JVM, default is 16GB, you may need over 32GB for a UK build)
- REG (the region, here set to 1 for Wales, 2 for Scotland, 3 for England, and 4 for UK)
- OTP_JAR (the OTP jar file version, here set to 1.3.0 by default)
Then run the created image using:
docker run -p 8080:8080 <tag_name>
Q: Do I need an OpenStreetMap (.osm) file to build a graph?
A: Yes, whilst you can build the graph without an .osm file. You will need it to analyse the graph.
Q: Do I need a GTFS file to build a graph?
A: An OpenTripPlanner server can be built without a General Transit Feed Specification (GTFS) dataset. However, a GTFS feed is required to analyse public transport. Without it you can analyse car, bicycle, and foot transport using OpenStreetMap (OSM) data.
Q: I found a bug!
A: Please use the GitHub issues form to provide us with the information.
Authors / Contributors
Data Science Campus - Office for National Statistics
Contributions and Bug Reports
We welcome contributions and bug reports. Please do this on this repo and we will endeavour to review pull requests and fix bugs in a prompt manner.
The Open Government Licence (OGL) Version 3
Copyright (c) 2018 Office of National Statistics
This source code is licensed under the Open Government Licence v3.0. To view this licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3 or write to the Information Policy Team, The National Archives, Kew, Richmond, Surrey, TW9 4DU.