GTFS File Creation

GTFS files describe routes that public transport run along. GTFS is a Google specification

Build the route (build the shapes.txt file)

  1. Import a gpx file (containing GPS lat/lon data) into google maps. Or if you have no gps path you can digitise a route in google maps by drawing lines.

         http://maps.google.ie
         My Maps > Create New Map > Import gpx file.

      2.  On layers, check all layers that you want to export. Every GPX file imported gets its own layer.

      3.  Choose "Export to KML" when you are happy the lines representing the routes are correct. Edit the lines in google maps if required.
      4.  Convert KML file to shapes.txt file in two ways:
           a. Upload KML here and copy output to a file called shapes.txt file:
              http://bdferris.github.io/kml-to-gtfs-shapes/
           b. OR use Googles "kmlparser.py" file packaged with transitfeed. Recommended to use this!
              https://github.com/google/transitfeed/
           For example:
           cd ~/Documents/feedvalidator
           ./kmlparser.py /path/to/file/myfile.kml nameOfOutputZipFile.zip

          ZIP generated contains two files. We only require the shapes.txt file here.
            shapes.txt e.g
            shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled
            Dubai,25.22166481,55.28944169,1,
            Dubai,25.22172533,55.28919015,2,
            stops.txt e.g
            stop_lon,stop_name,stop_lat,stop_id
            55.29654994,End of Dubai,25.18918832,1
            55.28944169,Start of Dubai,25.22166481,0.

Build Program That Creates Files Describing "Trips"

  1. Googles transitfeed provides an example program to build the other required GTFS files (stops.txt, trips.txt etc).
          https://github.com/google/transitfeed/
    cd /path/to/unzipped/transitfeed
    The example program is OK but doesn't show some of the syntax required to define all the aspects of trips required. To use the example program just copy and edit as required.
         cp small_builder.py build_davra_trips.py
    Alternatively use the file below - it is the customised version of the example program.
         /path/to/file/in/repo TODO .... wojciech.padula has a copy of this file.
    Programming syntax examples are here:
        https://github.com/google/transitfeed/blob/master/tests/transitfeed/testtrip.py
        https://github.com/google/transitfeed/blob/master/tests/transitfeed/testroute.py
  2. After creating trips in the program file, run with:
        ./build_davra_trips.py
    Zip file is generated. Review files in zip google_gtfs.zip
  3. Add "shapes.txt" file to the zip file. This is the file generated by our "Build The Route" section.
  4. Confirm the "shape_id" key referenced in trips.txt matches the key specified in shapes.txt file.
  5. Validate program output by using another google tool in the transitfeed toolkit:
        feedvalidator.py google_gtfs.zip
    HTML report is generated. See the file "validation-results.html". Minor errors can be ignored.

Visually Verify GTFS File

  1. Validate the GTFS file visually using ScheduleViewer. The tool is found in the transitfeed toolkit.
    Background.... https://github.com/google/transitfeed/wiki/ScheduleViewer
  2. Google Developer Key is required to use ScheduleViewer. Register here:
        https://console.developers.google.com/
    Click on "Developers console" at bottom.
    Create a project in console.
    Get a JS api key. Further info here:
        https://developers.google.com/maps/documentation/javascript/get-api-key
    Click "Get a key" and retrieve API token e.g "AIzaSyAAV9kWv2s1Ex5tsyDDkuJZ5d0euIflPrD"
  3. Install python package dependency
        easy_install simplejson
  4. Run viewer tool:
        python transitfeed/schedule_viewer.py --key=KEY --feed=FEED
    For example:
        python schedule_viewer.py --key=AIzaSyAAV9kWv2s1Ex5tsyDDkuJZ5d0euIflPrD --feed=davra_gtfs.zip
  5. Open browser to view route and trips:
        http://localhost:8765/
    Map should display the route and stops and searchable trips.