How To Read GTFS Data?

7,955 views
Skip to first unread message

Christopher Tysh

unread,
Oct 24, 2016, 4:16:41 PM10/24/16
to GTFS-realtime
I am looking into developing an app using data from the St. Louis Metro. I'd like to use real time bus information. I was directed to this page on their website, but I do not understand even where to begin ... The Google GTFS pages seem to for transit providers to use for publishing data. The other links on the page lead to PB files, but I don't know how to open a PB file or what am I supposed to do with it? 


Thanks for you help in getting started here.

-Chris

Sean Barbeau

unread,
Oct 26, 2016, 5:03:19 PM10/26/16
to GTFS-realtime
Chris,
Here is the data from St. Louis Metro you'll need to get started:
  1. GTFS data - ftp://metrostlouis.org/Transit/google_transit.zip
  2. GTFS-realtime data
    1. TripUpdates (arrival/departure predictions) - http://www.metrostlouis.org/RealTimeData/StlRealTimeTrips.pb
    2. VehiclePositions - http://www.metrostlouis.org/RealTimeData/StlRealTimeVehicles.pb
You'll need to set up a server to convert this data into a REST API that your app can easily access.  I'd suggest starting with setting up an open-source OneBusAway server, using the above data and these instructions:

You can test your server setup with the open-source OneBusAway Android app:

...although you can also easily build your own app using the REST APIs that the OneBusAway server provides.

I'd also encourage you to consider contributing to an open-source project like OneBusAway to build new features on top of what others have done, rather than building your own from scratch (see list of OneBusAway apps on various platforms at http://onebusaway.org/).  I also noticed that Metro Transit has a link at the bottom of their developer page that you referenced that asks developers to contact them if there's something as a developer that you'd like to see that they aren't currently offering - I'd suggest you recommend that they consider setting up their own OneBusAway server, so you (and all other developers in St. Louis) don't need to do this yourself.

Finally, to get a high-level view of transit data/app ecosystem, you might want to check out this presentation I gave at APTA a while back on Open Transit Data:

Hope this helps!

Sean

Tyler Green

unread,
Oct 26, 2016, 10:36:21 PM10/26/16
to GTFS-realtime
Hi Chris,

A PB file is just a protocol buffer, a format created by Google for sending data over a connection. Its implementation is not critical to understand. To start, I would point you towards this repository of Google's GTFS-realtime bindings: https://github.com/google/gtfs-realtime-bindings.

This library supports several popular languages and has examples of how to quickly get the GTFS-realtime data out of a PB file and into your main software flow.

I hope this helps!

Christopher Tysh

unread,
Oct 28, 2016, 2:36:21 PM10/28/16
to GTFS-realtime
Thanks for all the info. It's been tough finding a good source for info on how to work with the data.

I was able to use the GTFS library for PHP to read/output the data, but still not clear how to interpret into something meaningful.

I will look into OneBusAway.

Marius Latinis

unread,
Nov 8, 2016, 8:18:53 AM11/8/16
to GTFS-realtime
What would be the shell equivalent to the following:

read_proto file.gtfs >readable_output.txt

that would take GTFS-realtime file as an input and dump a human-readable representation of it?

Benoit Boissinot

unread,
Nov 8, 2016, 8:21:59 AM11/8/16
to gtfs-r...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "GTFS-realtime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gtfs-realtime+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtfs-realtime/eefb6614-1025-4cbc-80e0-171a5ecc3dee%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
:wq

Marius Latinis

unread,
Nov 8, 2016, 8:43:04 AM11/8/16
to GTFS-realtime
To unsubscribe from this group and stop receiving emails from it, send an email to gtfs-realtim...@googlegroups.com.
I read that link. When I execute shell command 
protoc --decode_raw < message.bin
the output is something as follows:

2 {
1: "5061"
4 {
1 {
1: "954649-20150530-20150722"
5: "CBLE-9"
}
2 {
1: 0x42524a04
2: 0xbe9bda0e
3: 0x00000000
}
3: 30
5: 1435129175
7: "7638"
8 {
1: "5061"
}
}
}


How to improve from there? I suspect the proto command needs to know the GTFS proto definition to decode fields "1", "2", into names.
How to SIMPLY incorporate that into one shell command?

Sean Barbeau

unread,
Nov 8, 2016, 10:13:46 AM11/8/16
to gtfs-r...@googlegroups.com

--
You received this message because you are subscribed to a topic in the Google Groups "GTFS-realtime" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gtfs-realtime/umglqNtuJ_c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gtfs-realtime+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtfs-realtime/80309522-0498-4994-83a2-665a270d22f3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages