Awesome Open Source
Awesome Open Source

GTFS to a weighted directed acyclic graph

Input

This Python script takes a GTFS uncompressed folder. These may be generated from the tfl_gtfs repository.

Executing the script

Change to the src directory:

cd src

Execture the Python script and pass the location of your input file. In this case, it is found within a tmp directory.

python analysis.py -i ../tmp/tfl_gtfs_2017-02-07_05/

Example output:

python analysis.py -i ../tmp/tfl_gtfs_2017-02-07_05/
Converting GTFS data into usable format
Creating stop_times db
15204494  stop times loaded
Creating trips db
Creating stops db
Creating calendar db
Creating routes db
# There are often errors within GTFS datasets - a check is performed.
There are 0 missing records from the original 725
Dumping to file (../out/data_errors/missing_routes.json.gz)
Creating edges for services
15204494  stop_times loaded

Outputs

The output is a series of JSON files explaining unique edges.

edge example:

{
    "index":0,
    "polyline":[
      541479.9724723536,
      174563.1806094267,
      541689.0233260792,
      174629.198668519
    ],
    "modes":[
      "Bus"
    ],
    "edge_id":"490015018N490015477E",
    "negativeNode":"490015018N",
    "services":[
      {
        "route_id":"b15",
        "route_type":"Bus",
        "journey_time":60,
        "arrival_time":1446441660,
        "route_agency":"tfl",
        "departure_time":1446441600
      },
      {
        "route_id":"b15",
        "route_type":"Bus",
        "journey_time":60,
        "arrival_time":1446443460,
        "route_agency":"tfl",
        "departure_time":1446443400
      },
      {
        "route_id":"b15",
        "route_type":"Bus",
        "journey_time":60,
        "arrival_time":1446445260,
        "route_agency":"tfl",
        "departure_time":1446445200
      } ...
      "graph":"GTFS",
      "journey_time":60.0,
      "positiveNode":"490015477E"
  },
      

vertex example:

{
    "toid":"910GALRESFD",
    "index":0,
    "point":[
      51.854001,
      0.997437
    ]
  } ...

address example:

{
    "toid":"910GALRESFD",
    "text":"Alresford (Essex) Rail Station",
    "index":0
  } ...

Station PageRank output example

PageRank

Service headway output example

Weekday services (top) and weekend services (bottom)

Headway examples


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (1,143,903
Network (3,722
Transportation (263
Gtfs (235
Related Projects