The make_gtfs Module

class make_gtfs.make_gtfs.Feed(input_dir)

Bases: builtins.object

A class to gather all the GTFS files for a feed and store them in memory as Pandas data frames. Make sure you have enough memory! The stop times object can be big.

create_agency()

Create a Pandas data frame representing agency.txt and save it to self.agency.

create_all()

Create all Pandas data frames necessary for a GTFS feed.

create_calendar()

Create a Pandas data frame representing calendar.txt and save it to self.calendar. It is a dumb calendar with one service that operates on every day of the week.

create_routes()

Create a Pandas data frame representing routes.txt and save it to self.routes.

create_shapes()

Create a Pandas data frame representing shapes.txt and save it to self.shapes. Each route has one shape that is used for both directions of travel.

Will create self.routes if it does not already exist.

create_stop_times()

Create a Pandas data frame representing stop_times.txt and save it to self.stop_times.

Will create self.stops and self.trips if they don’t already exist.

create_stops()

Create a Pandas data frame representing stops.txt and save it to self.stops. Create one stop at the beginning (the first point) of each shape and one at the end (the last point) of each shape. This will create duplicate stops in case shapes share endpoints.

Will create self.routes if it does not already exist.

create_trips()

Create a Pandas data frame representing trips.txt and save it to self.trips. Trip IDs encode direction, service window, and trip number within that direction and service window to make it easy to compute stop times.

Will create self.calendar, self.routes, and self.shapes if they don’t already exist.

export(output_dir=None, as_zip=False)

Assuming all the necessary data frames have been created (as in create_all()), export them to CSV files in the given output directory. If as_zip is True, then instead write the files to a zip archive called gtfs.zip in the given output directory. If output_dir is None, then write to self.input_dir.

get_linestring_by_route(use_utm=False)

Given a GeoJSON feature collection of linestrings tagged with route short names, return a dictionary with structure route ID -> Shapely linestring of shape. If use_utm == True, then return each linestring in in UTM coordinates. Otherwise, return each linestring in WGS84 longitude-latitude coordinates.

Will create self.routes if it does not already exist.

get_service_windows()

Return self.config['service_windows'].

get_window_duration(window_name, units='s')

Return the duration of the given service window in the given units. Allowable units are ‘s’ (seconds), ‘min’ (minutes), ‘h’ (hours).

make_gtfs.make_gtfs.get_duration(timestr1, timestr2, units='s')

Return the duration of the time period between the first and second time string in the given units. Allowable units are ‘s’ (seconds), ‘min’ (minutes), ‘h’ (hours). Assume timestr1 < timestr2.

make_gtfs.make_gtfs.get_shape_id(route_id)
make_gtfs.make_gtfs.get_stop_ids(route_id)
make_gtfs.make_gtfs.get_stop_names(route_short_name)
make_gtfs.make_gtfs.main()

Get command line arguments, create feed, and export feed.

make_gtfs.make_gtfs.parse_args()

Parse command line options and return an object with two attributes: input_dir, a list of one input directory path, and output_file, a list of one output file path.

make_gtfs.make_gtfs.seconds_to_timestr(seconds, inverse=False)

Return the given number of integer seconds as the time string ‘%H:%M:%S’. If inverse == True, then do the inverse operation. In keeping with GTFS standards, the hours entry may be greater than 23.

make_gtfs.make_gtfs.timestr_mod_24(timestr)

Given a GTFS time string in the format %H:%M:%S, return a timestring in the same format but with the hours taken modulo 24.

Previous topic

Welcome to make_gtfs’s documentation!

This Page