Home

Awesome

gtfs-service-area

Compute a transit service area from static GTFS. Results are output as single-layer .geojson files.

NOTE: The functionality in this tool has been incorporated into the upstream gtfs-to-geojson. This repo is now read-only and is no longer maintained.

Examples

The example directory contains output using GTFS data from Big Blue Bus and Monterey-Salinas Transit, with settings from the sample config file in this repository.

Getting Started

Create a configuration file from the sample:

cp config.sample.json config.json

Edit the collection of agencies as needed:

"agencies": [
    {
        "agency_key": "agency1",
        "url": "https://www.agency1.com/gtfs.zip"
    },
    {
        "agency_key": "agency2",
        "url": "https://www.agency2.com/gtfs.zip"
    }
],

Option 1: Use docker-compose

docker-compose run pipeline

Option 2: Use npm

  1. Install dependencies:

    npm install
    
  2. Run the generator:

    npm start
    

Check the geojson directory for output:

.
├── geojson
│   ├── agency1
│   │   ├── agency1-routes.geojson  <-- GTFS route lines
│   │   ├── agency1-stops.geojson   <-- GTFS route stops
│   │   ├── agency1-service-area-1.geojson   <-- Computed service area(s)
│   │   └── agency1-service-area-2.geojson
│   ├── agency2
│   │   ├── agency2-routes.geojson  <-- GTFS route lines
│   │   ├── agency2-stops.geojson   <-- GTFS route stops
│   │   ├── agency2-service-area-1.geojson   <-- Computed service area(s)
│   │   └── agency2-service-area-2.geojson

Service Areas

This tool calculates service area using a number of different methods:

TypeDescription
envelopeBounding box around routes lines
convexConvex hull around route endpoints
stopsBuffer around stops
stops-dissolvedDissolve the buffer around stops

The configuration file allows for specifying which service area calculation(s) are used, per-agency and/or on the run as a whole, with the serviceAreas key:

{
  "agencies": [
    {
      "agency_key": "agency1",
      "url": "https://www.agency1.com/gtfs.zip",
    },
    {
      "agency_key": "agency2",
      "url": "https://www.agency2.com/gtfs.zip",
      "serviceAreas": [
        "stops"
      ]
    }
  ],
  "serviceAreas": [
    "envelope",
    "convex",
    "stops",
    "stops-dissolved"
  ]
}

In the above example:

Stop Buffers

For the stops and stops-dissolved calculation, an additional configuration key bufferRadiusMeters can be specified, either at the top-level or per-agency, to control the radius of buffers (in meters):

{
  "agencies": [
    {
      "agency_key": "agency1",
      "url": "https://www.agency1.com/gtfs.zip",
      "serviceAreas": [
        "stops"
      ]
    },
    {
      "agency_key": "agency2",
      "url": "https://www.agency2.com/gtfs.zip",
      "serviceAreas": [
        "stops-dissolved"
      ],
      "bufferSizeMeters": 750
    }
  ],
  "bufferSizeMeters": 400
}

In the above example:

Additional Configuration

The configuration data is passed through to gtfs-to-geojson, and you may use any of the supported options.

Note that this project may override some options as necessary for calculating service areas.