OSM2GTFS for Accra - user manual

From OpenStreetMap Wiki
Jump to: navigation, search

OSM2GTFS for Accra - User's manual

During AccraMobile3, the Jungle Bus team worked on a the creation of a GTFS file, using OSM2GTFS tool.

The file is freely available here : https://github.com/AFDLab4Dev/AccraMobility/tree/master/GTFS

This page explains how to update this file.

Introduction

The purpose of OSM2GTFS is to provide an easy to use tool to generate transit data from OpenStreetMap in a worldwide standard format called GTFS.

The generated GTFS data feed can then be used in a large collection of tools, such as TransitApp or navitia.io, to :

  • provide journey computation
  • provide next departures boards
  • enable transit network analyses to look for improvements
  • provide access informations to improve marketing campaigns of shops or retail companies
  • etc

How to use

Prerequisites

This manual is assuming that the user is running a Ubuntu Distribution with a fully functional python2.7 environment and git package already installed.

Installing the software

1. Create a directory that will contain the tool (for exemple `mkdir ~/osm2gtfs`)

2. In the previously created directory, copy the sources : `git clone https://github.com/nlehuby/osm2gtfs/`

The official repository is `https://github.com/grote/osm2gtfs/`, but some changes are in progress and could make the use of the tool difficult or change the generated GTFS feed.

3. install the dependencies : `pip install -e .` The python-overpy and transitfeed python packages will be installed. If an error occurs, try to run the command with root privileges `sudo pip install -e .`

Running the Accra GTFS feed generation

1. Change the current directory to the osm2gtfs directory (`cd ~/osm2gtfs/osm2gtfs` if you used the previous path)

2. First, delete the cache files to update informations from OpenStreetMap. The files are located in the `data` directory (`~/osm2gtfs/osm2gtfs/data/`) and the files are named `stops-accra.pkl` and `routes-accra.pkl`.

For example, you can run the following command : `rm data/*.pkl`

3. Run the program with only the accra configuration file to generate the GTFS feed : `osm2gtfs -c ./creators/accra/accra.json`

While running, osm2gtfs is making a lot of call to an external API called Overpass (http://overpass-turbo.eu/) to collect OSM data and record them locally in the cache files previously deleted.

Sometimes, the load of the Overpass server is too high, and replies with an error. In those cases, simply run again the program, osm2gtfs will resume the data collection from the last error.

The GTFS file is generated in the ./data folder with the file name specified in the Accra config file. For exemple : `~/osm2gtfs/data/accra.zip`

4. Check the generated GTFS :

In the ZIP file, you should find 9 files, and specifically  :

  • a "feed_info.txt" that contains the validity of the feed. Check the "feed_end_date" value, it should be at least 3 months from now
  • a "routes.txt" file containing more than 270 rows (one row for each public transport line in Accra)
  • a "stops.txt" file containing more than 4000 stops
  • a non empty "stop_times.txt"

Publishing the generated data

1. Make sure the GTFS feed is named "GTFS_Accra.zip" (and rename it if not)

2. Open in a web browser the AFD repository : https://github.com/AFDLab4Dev/AccraMobility/tree/master/GTFS

3. Upload the GTFS_Accra.zip file using the "Upload files" button

4. In the commit title form, set the message "Update of Accra GTFS - 20171231" changing the date accordingly to the current day (in the format YYYY MM DD), select "push on master" and click on the "commit" button


And what if ...

What if the validity of the feed less than 3 months away ?

Open the "osm2gtfs/creators/accra/accra.json" file and change the value associated to the "end_date" property of the "feed_info" object.

What if the program is not properly running ?

If you can't make the program run properly, open an issue in GitHub in the project https://github.com/nlehuby/osm2gtfs/ and try to describe the problem and the encountered error.