osm2gtfs, extendable for any city

Convert data from OpenStreetMap into GTFS

osm2gtfs announcement

The Nicaraguan OpenStreetMap Community started some years ago a public transport project to create the first proper bus map of a Central American city. Once the data has been collected in a collective crowd-sourcing process directly on OpenStreetMap, a paper map has been created. In a next step this data should be made available in different applications. The most obvious and best path was to rely on the common format GTFS, which can be easily integrated in most public transport routing solutions.

At this point, checking different options to convert OpenStreetMap data into GTFS - unfortunately none was satisfying. Within this desk study I also stumbled over the python script osm2gtfs, by Torsten Grote, the creator of the great Free and Open Source public transport application Transportr. This script was targeted to only work for Florianopolis in Brasil. It grabbed data from OpenStreetMap, parsed online information about schedule from the bus operators' website and created a GTFS out of it.

osm2gtfs was not ready to be used for any other city, but it seemed to be the best option to further develop: it relied on suitable libaries like transitfeed and it was programmed in Python, which I think was a good choice. So I teamed up with the maintainer and Jaime from the Costa Rican OpenStreetMap community, to evolve osm2gtfs into a useful tool for many cities. Together, we basically rewrote the initial script into a new structure, which is flexibly extendable for other cities, different sources for time schedule information and introduced a general standard process, which could work for many cities also without programatically extending the Software.

Due to the implemented changes it allowed at a later stage, more initiatives to join the effort: Accra Mobility, a project by the French Development Agency, directly through our partner initiative JungleBus, who extended the osm2gtfs to produce the GTFS for the capital and largest city of Ghana.

And also in Nicaraguan, in the northern city of Estelí, internatioal weltwärts volunteers picked up the dream of mapping the public transport system there. They made it happen, and collaborated extensively with the osm2gtfs Software package.

osm2gtfs is a community based initiative for the development of a versatil tool to convert data from OpenStreetMap about public transport, combine it with external schedule information in order to create a General Transit Feed (GTFS). The Software has been programmed by community members of Brasil, Nicaragua, Costa Rica and France. Now osm2gtfs can be used without any programming skills, whenever using our defined input format. And, of course, with programming skills it is always flexibly extendedable to support any other city's particularities and sources for schedules.

If you are interested to convert OpenStreetMap data into GTFS, check out the documentation and feel free to communicate over the project's issue queue or contact us directly. Of course any contribution is highly appreciated.

How does it work?

The script retrieves current data about public transport networks directly from OpenStreetMap via the Overpass API. It stores the data in python objects and caches on disk for efficient re-use. Then the data is combined with another source of schedule (time) information in order to create a GTFS file using the transitfeed library.

For every new city a new configuration file needs to be created. Additionally, schedule information should be provided. By-default the schedule information is expected to be provided in a certain format. However other formats are supported through extending the code. For any city and schedule format the script can be easily extended, see the developer documentation for more information.