Skip to content

Code to calculate station-station distances along MBTA routes

Notifications You must be signed in to change notification settings

transitmatters/route-lengths

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MBTA Route Lengths

This is code to calculate the length of MBTA routes from GTFS bundles. The output takes the form of a JSON file with this structure:

{
    "Green-B": [
        {
            "from_station_id": "place-lake",
            "to_station_id": "place-sougr",
            "from_station_name": "Boston College",
            "to_station_name": "South Street",
            "distance": 0.76
        },
        {
            "from_station_id": "place-sougr",
            "to_station_id": "place-chill",
            "from_station_name": "South Street",
            "to_station_name": "Chestnut Hill Avenue",
            "distance": 0.45
        },
        ...
    ],
    "Green-C": [
        ...
    ],
    ...
}

Installing

Requirements:

To install dependencies:

poetry install

Configuring the script

To configure the script, copy config.example.json to config.json and edit the values as needed.

  • feedsPath is a path to any directory on your computer where you'd like to hold a cache of GTFS bundles. The script will automatically download them and store them here. Other TM tools use this same directory, so if you already have it set up, you can use the same path.
  • targetRouteIds is a list of route IDs to calculate the length of. You can find a list of route IDs in the routes.txt file in any GTFS bundle.

Here's an example config.json:

{
    "feedsPath": "~/path/to/feeds/somewhere",
    "targetRouteIds": [
        "Green-B",
        "Green-C",
        "Green-D",
        "Green-E"
    ]
}

You can use the special value "*" to query all route IDs.

Running the script

To run the script, run this command:

make run

This might take a while to run the first time, since it has to download a GTFS bundle. Subsequent runs will be faster.

About

Code to calculate station-station distances along MBTA routes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published