MARTA Developer Resources

This is my attempt to catalog information related to the MARTA's developer feeds – both for my own use and for the benefit of other programmers.

My personal opinion is that the community would be better served if this were hosted on the MARTA website, so I will happily turn over these files – at no charge, of course – if they give MARTA a head start to hosting a more detailed set of developer pages. (But I would appreciate attribution for my work.)

Contact

Please be aware that I am not affiliated with MARTA. Contact information for MARTA can be found on the agency's website at:
http://www.itsmarta.com/Contact-us.aspx

If you would like to contact me about this resource (and please feel welcome to do so, especially if you find any errors I need to correct), my e-mail address is joe@joederose.us.

Real-Time Data

MARTA has a real-time bus feed that provides data in XML (via a SOAP call) and JSON (both via SOAP and via a RESTful call). MARTA wants to be aware of any developers using the real-time feed, so I am not providing links to it here; instead, you will need to submit a request on the MARTA developer page at http://www.itsmarta.com/brd-request-form.aspx. After you submit that form, you will immediately be taken to a page with instructions on using the system. Since those instructions are a bit overwhelming on the first visit, here's what it boils down to for access to the (easier and more complete) RESTful feed:

Once you have the URL, you can retrieve information as follows:

URL Result
http://.../GetAllBus Gets the results for all active buses on all routes
http://.../GetBusByRoute/{Route} Replace "{Route}" with a route number (e.g., "3" or "99"). Gets the results for all buses on the selected route.

This will return an array of JSON objects (one JSON object per bus), that looks like this:

[{"ADHERENCE":"0","BLOCKID":"2","BLOCK_ABBR":"1-2","DIRECTION":"Southbound","LATITUDE":"33.7562339","LONGITUDE":"-84.3918858","MSGTIME":"4\/7\/2013 12:42:43 PM","ROUTE":"1","STOPID":"904680","TIMEPOINT":"Luckie St & North Ave.","TRIPID":"3698436","VEHICLE":"2981"},{"ADHERENCE":"-3","BLOCKID":"1","BLOCK_ABBR":"1-1","DIRECTION":"Northbound","LATITUDE":"33.7889023","LONGITUDE":"-84.4262254","MSGTIME":"4\/7\/2013 12:51:21 PM","ROUTE":"1","STOPID":"901556","TIMEPOINT":"Huff Rd & Howell Mill","TRIPID":"3713428","VEHICLE":"2853"}]

Following, as best I understand them, are the meanings for the field names:

Field Name Notes
ADHERENCE 0 = on time; negative numbers show the number of minutes the bus is late; positive numbers show the number of minutes the bus is early.
BLOCKID (I don't yet know what this means.)
BLOCK_ABBR (I don't yet know what this means.)
DIRECTION Direction of the bus. This information is usually accurate – but it does not match any field in the GTFS data (see below). this is less of a problem than it used to be, as MARTA is now providing the TRIPID field in the real-time data.
LATITUDE Latitude in decimal WGS 84 format.
LONGITUDE Latitude in decimal WGS 84 format.
MSGTIME This is not the time that the bus most recently reported its location, but rather the time that it most recent passed a time-point stop. There is no information in the GTFS data (see below) about which stops are time-point stops – but that information can be found on the online bus schedules on the MARTA website.
ROUTE The bus number. Correlates to stops.route_short_name in the GTFS data (see below).
STOPID The stop code for the most recent time-point stop. Correlates to stops.stop_id in the GTFS data.
TIMEPOINT Plain text giving the location of the most recent time-point stop.
TRIPID Correlates to trips.trip_id in the GTFS data.
VEHICLE The bus number. (Does not correlate to any field in the GTFS data, but is nonetheless a useful value as it is visible to riders.)

GTFS (General Transit Feed Specification)

Source Information

The MARTA GTFS feed is available on the MARTA website at:
http://www.itsmarta.com/marta-developer-resources.aspx

This feed was designed for Google Transit, and meets Google's specifications as outlined at
https://developers.google.com/transit/gtfs/reference

UML

Following is a UML diagram of the table relationships in MARTA's GTFS feed. I included calendar.txt and calendar_dates.txt on this example to show the field relationship, but I think a query that incorporates these tables would be needlessly complex. For my own work, I plan to set up separate function calls to get the appropriate service_id from those tables, and simply pass in the resultant value as a parameter in the WHERE clause of the query.

UML of table relationships

Tables (.txt Files)

Following are the tables provided in the MARTA GTFS feeds. Please note the following:

Table: agency.txt

This table provides information about the transit agency (in our case, MARTA).

Field Name Data Type Notes
agency_id text(5)  
agency_name text(44)  
agency_url text(23)  
agency_timezone text(16)  
agency_lang text(2)  
agency_phone text Not used by MARTA in the current data set.

Data Example

agency_id agency_name agency_url agency_timezone agency_lang agency_phone
MARTA Metropolitan Atlanta Rapid Transit Authority http://www.itsmarta.com America/New_York en  

Table: stops.txt

This table provides information about specific transit stops and stations.

Field Name Data Type Notes
stop_id integer This is the numeric code that is also displayed as the "Stop Number" on MARTA's MyCommute pages.
stop_code integer  
stop_name text(35)  
stop_desc text(81) Google instructs that this should be a description of the stop with "useful, quality information" to distinguish it from stop_name; MARTA does not seem to be using it to its potential, and in some cases leaves it blank. Dropped by MARTA in the data feed of March 7, 2013.
stop_lat float Latitude in decimal WGS 84 format.
stop_lon float Longitude in decimal WGS 84 format.
zone_id integer Not used by MARTA in the current data set. Dropped by MARTA in the data feed of March 7, 2013.
stop_url text Not used by MARTA in the current data set. Dropped by MARTA in the data feed of March 7, 2013.
location_type integer Not used by MARTA in the current data set. Dropped by MARTA in the data feed of March 7, 2013.
parent_station integer Not used by MARTA in the current data set. Dropped by MARTA in the data feed of March 7, 2013.

Data Example

stop_id stop_code stop_name stop_desc stop_lat stop_lon
99174 900992 MARTIN LUTHER KING J DR@RACINE ST 0 MARTIN LUTHER KING J & RACINE 33.75142 -84.4413
99176 900934 MARTIN LUTHER KING J DR@GORDON TER 0 MARTIN LUTHER KING J & GORDON 33.75101 -84.4427
99178 900935 MARTIN LUTHER KING J@1444   33.75338 -84.4349
99186 900936 BARFIELD AVE SW@WINGATE ST SW 0 BARFIELD AVE SW & WINGATE ST SW 33.74889 -84.4617
99188 900937 BARFIELD AVE SW @ LARCHWOOD ST SW 0 BARFIELD AVE SW & LARCHWOOD ST SW 33.74764 -84.4617

Table: routes.txt

This table provides information about specific transit stops and stations.

Field Name Data Type Notes
route_id integer  
agency_id text Probably intended to be an integer like the other "_id" fields, but assigned a text value in agency.txt, so I made it a text value here even though it is not used. Not used by MARTA in the current data set. Dropped by MARTA in the data feed of March 19, 2013.
route_short_name text(5) Must be imported as text rather than as an integer because the heavy rail line designations in this field use the line colors (see data sample below)
route_long_name text(35)  
route_desc text Not used by MARTA in the current data set.
route_type integer 3 = bus; 1 = subway/metro; see the Google specification for more information.
route_url text Not used by MARTA in the current data set.
route_color text(6) Hexadecimal triplet representing RGB color. Cannot be more than 6 characters.
route_text_color text(6) Hexadecimal triplet representing RGB color. Cannot be more than 6 characters. Not used by MARTA in the current data set.

Data Example

route_id agency_id route_short_name route_long_name route_desc route_type route_url route_color route_text_color
7479   1 Centennial Oly. Park/Coronet Way   3   FFFF00  
7480   2 Ponce de LeonĀ  Ave/Moreland Ave   3   00FF00  
7481   3 Martin Luther King Jr. Dr/Auburn Av   3   008080  
7574   BLUE BLUE-East/West Line   1   00FFFF  
7576   GOLD GOLD-Northeast Doraville Line   1   FFFF00  

Table: trips.txt

This table provides information about specific transit trips (meaning from one end-point of a route to the other).

Field Name Data Type Notes
route_id integer  
service_id integer Relates to the service_id field in the calendar.txt file; essentially, though: 3 = Saturday, 4 = Sunday, and 5 = weekday
trip_id integer  
trip_headsign text(64)  
direction_id integer Must be either 0 or 1; see my direction_id page for information on MARTA's implementation.
block_id integer  
shape_id integer  

Data Example

route_id service_id trip_id trip_headsign direction_id block_id shape_id
7480 3 2069608 2 NORTH AVE STA 0 825129 48064
7480 3 2069609 2 NORTH AVE STA 0 825129 48064
7480 3 2069610 2 NORTH AVE STATION VIA NORTH AVE 0 825130 48063
7480 3 2069642 2 PONCE DE LEON - CANDLER PARK STA 1 825129 48066
7480 3 2069643 2 DECATUR STATION VIA NORTH AVE 1 825130 48065

Table: stop_times.txt

This table provides information about stop times.

Field Name Data Type Notes
trip_id integer  
arrival_time text(8) Cannot be more than 8 characters. Looks like it should be imported as a time field, but the Google specification of showing times after midnight as 24:xx:xx, 25:xx:xx, 26:xx:xx, etc. may cause database errors; a better approach is to import it as text and parse it into hours, minutes, and seconds (some techniques are shown below).
departure_time text(8) Cannot be more than 8 characters. Looks like it should be imported as a time field, but the Google specification of showing times after midnight as 24:xx:xx, 25:xx:xx, 26:xx:xx, etc. may cause database errors; a better approach is to import it as text and parse it into hours, minutes, and seconds (some techniques are shown below). In the MARTA GTFS feed, arrival_time and departure_time are always the same.
stop_id integer  
stop_sequence integer  
stop_headsign text Not used by MARTA in the current data set. Dropped by MARTA in the data feed of February 6, 2013.
pickup_type integer 0 = regular pickup; 1 = no pickup (of which there are a handful of examples in the MARTA GTFS feed). Dropped by MARTA in the data feed of February 6, 2013.
drop_off_type integer 0 = regular drop off; 1 = no drop off (of which there are a handful of examples in the MARTA GTFS feed). Dropped by MARTA in the data feed of February 6, 2013.
shape_dist_traveled float In kilometers. Unlike with the similar field in shapes.txt, MARTA leaves the field null, rather than displaying 0, at the beginning of the route. Dropped by MARTA in the data feed of February 6, 2013.

Data Example

trip_id arrival_time departure_time stop_id stop_sequence
2069593 5:56:00 5:56:00 84901 1
2069593 5:56:36 5:56:36 84386 2
2069593 5:56:56 5:56:56 105302 3
2069593 5:57:15 5:57:15 84384 4
2069593 5:57:32 5:57:32 84380 5

Parsing the arrival_time and departure_time fields into hour, minute, and second values is very straightforward. Most languages have a mechanism for manipulating strings based on regular expressions, and the VBA (VisualBasic for Applications) examples below illustrate a pretty common framework for parsing the information in languages without support for regular expressions. These techniques will return a text value; likely you'll want to convert it to a numerical value using the appropriate function in the language you're using – usually some variation of val(), value(), Integer() or parseInt().

To Get Regular Expression
Empty String Replacement
Regular Expression
Backreference Replacement
VBA
Hour departure_time.replace( /:\d+:\d+$/, "" ) departure_time.replace( /(\d+):(\d+):(\d+)/, "$1" ) Left([departure_time],Len([departure_time])-6)
Minute departure_time.replace( /^\d+:|:\d+$/g, "" ) departure_time.replace( /(\d+):(\d+):(\d+)/, "$2" ) Left(Right([departure_time],5),2)
Second departure_time.replace( /^\d+:\d+:/, "" ) departure_time.replace( /(\d+):(\d+):(\d+)/, "$3" ) Right([departure_time],2)

Table: calendar.txt

This table provides information about the routine schedule.

Field Name Data Type Notes
service_id integer Essentially 3 = Saturday, 4 = Sunday, and 5 = weekday
monday integer 0 = no service on Monday; 1 = service on Monday
tuesday integer 0 = no service on Tuesday; 1 = service on Tuesday
wednesday integer 0 = no service on Wesnesday; 1 = service on Wednesday
thursday integer 0 = no service on Thursday; 1 = service on Thursday
friday integer 0 = no service on Friday; 1 = service on Friday
saturday integer 0 = no service on Saturday; 1 = service on Saturday
sunday integer 0 = no service on Sunday; 1 = service on Sunday
start_date text(8) Cannot be more than 8 characters. Date in YYYYMMDD format.
end_date text(8) Cannot be more than 8 characters. Date in YYYYMMDD format.

Data Example

service_id monday tuesday wednesday thursday friday saturday sunday start_date end_date
3 0 0 0 0 0 1 0 20120825 20131214
4 0 0 0 0 0 0 1 20120825 20131214
5 1 1 1 1 1 0 0 20120825 20131214

Table: calendar_dates.txt

This table provides information about interruptions in the schedule (usually for holiday service).

Field Name Data Type Notes
service_id integer  
date text(8) Cannot be more than 8 characters. Date in YYYYMMDD format.
exception_type integer 1 = service added for a date; 2 = service removed for a date. When weekday service is changed to Saturday or Sunday service for a holiday, there are two lines for the date in question: one to remove the weekday service (exception_type = 2; service_id = 5) and another to add the appropriate alternate service (exception_type = 1; service_id = 3 or 4)

Data Example

service_id date exception_type
4 20120903 1
5 20120903 2
4 20121122 1
5 20121122 2
3 20121123 1
5 20121123 2

Table: shapes.txt

This table provides information for drawing a map of a route.

Field Name Data Type Notes
shape_id integer  
shape_pt_lat float Latitude in decimal WGS 84 format.
shape_pt_lon float Longitude in decimal WGS 84 format.
shape_pt_sequence integer  
shape_dist_traveled float In kilometers. Unlike with the similar field in stop_times.txt, MARTA displays 0 rather than null at the beginning of the route. Dropped by MARTA in the data feed of February 6, 2013.

Data Example

shape_id shape_pt_lat shape_pt_lon shape_pt_sequence
48058 33.78635 -84.4117 1
48058 33.78777 -84.41182 2
48058 33.786349 -84.411699 3
48058 33.785799 -84.41168 4
48058 33.784229 -84.41191 5