routes
gtfs.routes
Helpers for working with routes.txt.
Functions
Name | Description |
---|---|
get_saved_route_type_lookup | Get the locally saved route type lookup as a dataframe. |
scrape_route_type_lookup | Scrape a lookup of GTFS route_type codes to descriptions. |
get_saved_route_type_lookup
gtfs.routes.get_saved_route_type_lookup(path=pathlib.Path(os.path.join(PKG_PATH, 'data', 'gtfs', 'route_lookup.pkl')))
Get the locally saved route type lookup as a dataframe.
Parameters
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, pathlib.Path] | The path to the route type lookup, defaults to os.path.join(PKG_PATH, “data”, “gtfs”, “route_lookup.pkl”) | pathlib.Path(os.path.join(PKG_PATH, 'data', 'gtfs', 'route_lookup.pkl')) |
Returns
Type | Description |
---|---|
pd.DataFrame | The route type lookup |
scrape_route_type_lookup
gtfs.routes.scrape_route_type_lookup(gtfs_url='https://gtfs.org/schedule/reference/', ext_spec_url='https://developers.google.com/transit/gtfs/reference/extended-route-types', extended_schema=True)
Scrape a lookup of GTFS route_type codes to descriptions.
Scrapes HTML tables from gtfs_url
to provide a lookup of route_type
codes to human readable descriptions. Useful for confirming available modes of transport within a GTFS. If extended_schema
is True, then also include the proposed extension of route_type to the GTFS.
Parameters
Name | Type | Description | Default |
---|---|---|---|
gtfs_url |
str | The url containing the GTFS accepted route_type codes. Defaults to “https://gtfs.org/schedule/reference/”. | 'https://gtfs.org/schedule/reference/' |
ext_spec_url |
str | The url containing the table of the proposed extension to the GTFS schema for route_type codes. Defaults to ( “https://developers.google.com/transit/gtfs/reference/” “extended-route-types” ). | 'https://developers.google.com/transit/gtfs/reference/extended-route-types' |
extended_schema |
bool | Should the extended schema table be scraped and included in the output? Defaults to True. | True |
Returns
Type | Description |
---|---|
pd.core.frame.DataFrame | A lookup of route_type codes to descriptions. |
Raises
Type | Description |
---|---|
ValueError | gtfs_url or ext_spec_url are not “http” or “https” protocol. |
TypeError | extended_schema is not of type bool. |