Tag: Pace

Converting a transit agency’s GTFS to shapefile and GeoJSON with QGIS

Many years ago I wrote a tutorial on how to use an ArcGIS plugin to convert a transit agency’s GTFS package – a group of files that describe when and where their buses and trains stop – into files that could easily be manipulated by popular GIS desktop software.

That was so long ago, before I became an expert in using QGIS, a free and open source alternative to ArcGIS.

This tutorial will show you how to convert GTFS to a shapefile and to GeoJSON so you can edit and visualize the transit data in QGIS.

Prerequisites

First you’ll need to have QGIS installed on your computer (it works with Linux, Mac, and Windows). Second you’ll need a GTFS package for the transit agency of your choice (here’s the one for Pace Suburban Bus*, which operates all suburban transit buses in Chicagoland). You can find another transit agency around the world on the GTFS Data Exchange website.

Section 1: Let’s start

  1. Open QGIS.
  2. Load your GTFS data into the QGIS table of contents (also called the Layers Panel). Click Layer>Add Layer>Add Delimited Text Layer. You will be adding one or two files depending on which ones are provided.

    QGIS add delimited text layer

    Add delimited text layer.

  3. Now, here it can get tricky. Not all transit agencies provide a “shapes.txt” file. The shapes.txt file draws out the routes of buses and trains. If it’s not provided, that’s fine, but if you turn them into routes based on the stops.txt data, then you will have funny looking and impossible routes.

    QGIs browse for the stops.txt file

    Browse for the stops.txt file

  4. Click on “Browse…” and find the “stops.txt”. QGIS will read the file very quickly and determine which fields hold the latitude and longitude coordinates. If its determination is wrong, you can choose a different “X field” (longitude) and “Y field” (latitude).
  5. Click “OK”. A new dialog box will appear asking you to choose a coordinate reference system (EPSG). Choose or filter for “WGS 84, EPSG:4326”. Then click “OK”.
  6. The Pace bus stops in the Chicagoland region are now drawn in QGIS!

    Pace bus stops are shown

    Pace bus stops are shown

  7. If the GTFS package you downloaded includes a “shapes.txt” file (that represents the physical routes and paths that the buses or trains take), import that file also by repeating steps 4 and 5.

Section 2: Converting the stops

It’s really easy now to convert the bus or train stops into a shapefile or GeoJSON representing all of those points.

  1. Right-click the layer “stops” in the table of contents (Layers Panel) and click “Save As…”.
  2. In the “Save vector layer as…” dialog box, choose the format you want, either “ESRI Shapefile” or “GeoJSON”. **
  3. Then click “Browse” to tell QGIS where in your computer’s file browser you want to save the file. Leave the “CRS” as-is (EPSG:4326).

    Convert the bus stops to a shapefile or GeoJSON.

    Convert the Pace bus stops to a shapefile or GeoJSON.

  4. Then click “OK” and QGIS will quickly report that the file has been converted and saved where you specified in step 3.

Section 3: Converting the bus or train routes

The “shapes.txt” file is a collection of points that when grouped by their route number, show the physical routes and paths that buses and trains take. You’ll need a plugin to make the lines from this data.

  1. Install the plugin “Points to Paths”. Click on Plugins>Manage and Install Plugins… Then click “All” and search for “points”. Click the “Points to Paths” plugin and then click the “Install plugin” button. Then click “Close”.

    Install the Points to Paths plugin.

    Install the Points to Paths plugin.

  2. Pace bus doesn’t provide the “shapes.txt” file so we’ll need to find a new GTFS package. Download the GTFS package provided by the Chicago Transit Authority, which has bus and rail service in Chicago and the surrounding municipalities.
  3. Load the CTA’s “shapes.txt” file into the table of contents (Layers Panel) by following steps 4 and 5 in the first section of this tutorial.  Note that this data includes both the bus routes and the train routes.

    QGIS load CTA bus and train stops

    Import CTA bus and train stops into QGIS

  4. Now let’s start the conversion process. Click on Plugins>Points to Paths. In the next dialog box choose the “shapes” layer as your “Input point layer”.
  5. Select “shape_id” as the field with which you want to “Point group field”. This tells the plugin how to distinguish one bus route from the next.
  6. Select “shape_pt_sequence” as the field with which you want to “Point order field”. This tells the plugin in what order the points should be connected to form the route’s line.
  7. Click “Browse” to give the converted output shapefile a name and a location with your computer’s file browser.
  8. Make sure all  of the options look like the one in this screenshot and then click “OK”. QGIS and the plugin will start working to piece together the points into lines and create a new shapefile from this work.

    These are the options you need to set to convert the CTA points (stops) to paths (routes).

    These are the options you need to set to convert the CTA points to paths (routes).

  9. You’ll know it’s finished when the hourglass or “waiting” cursor returns to a pointer, and when you see a question asking if you would like the resulting shapefile added to your table of contents (Layers Panel). Go ahead and choose “Yes”.

    QGIS: CTA bus and train points are converted to paths (routes)

    The CTA bus and train points, provided in a GTFS package, have been converted to paths (routes/lines).

  10. Now follow steps 1-4 from Section 3 to convert the routes/lines data to a shapefile or GeoJSON file.**

Notes

* As of this writing, the schedules in Pace’s GTFS package are accurate as of January 18, 2016. It appears their download link always points to the latest version. Transit schedules typically change several times each year. Pace says, “Only one package is posted at any given time, typically representing Pace service from now until a couple of months in the future. Use the Calendar table to see on which days and dates service in the Trips table are effective.”

** Choose GeoJSON if you want to show this data on a web map (like in Leaflet or the Google Maps API), or if you want to share the data on GitHub.

Exploring Pace’s locations for mysterious Arterial Rapid Transit bus stations on Milwaukee Avenue

intersection of Touchy and Milwaukee in Niles

This is the semi-urban scene at Touhy and Milwaukee Avenue. The police station is ahead on the right. The water fountain (described below) is behind the bus on the left. There are multi-unit buildings to the left and across the street on the right. Image: Google Streetview

Update, Jan 21, 2015: Pace unveiled their plan for ART and their request to Congress to make the ART plan a project of regional significance to attract more funding.

Pace, the suburban bus operator in Chicagoland, is constructed an Arterial Rapid Transit bus route on Milwaukee Avenue from the Jefferson Park Transit Center in Chicago – a busy intermodal station where Metra and CTA buses and trains stop – to Golf Mill Mall in Niles. Both of these are major transfer hubs.

I’ve never looked into ART bus systems before but it seems to resemble what many call BRT Lite. Pace has minimal information on its website. Daniel Hertz, notable bus transit supporter, pointed me to an RFP [PDF, 10 MB] that describes the location and scope of Pace’s first (of many) ART corridors.

The RFP describes this project as one of 24 corridors outlined in its Vision 2020 document “to provide a regional network of premium transit services”. It appears that premium is relative and that bus riders will have a more comfortable and easier-to-find bus station at which to wait – bus travel time will not change.

I’ll try to paint you a picture of the built environment going north to south at the eight intermediate stops.

Dempster Street, Niles

Milwaukee has six general purpose lanes here and Dempster has six, four of which go under Milwaukee; buildings are set back far from the curb and land uses are low-density and optimized for arriving in a car

Main Street, Niles

Milwaukee has four general purpose lanes and one wide parking lane here; Main is a two-lane street; there is some residential on both streets

Oakton Street, Niles

Milwaukee and Oakton both have four general purpose lanes

Harlem Avenue, Niles

this intersection has decades-old buildings that have limited parking up front and smaller setbacks; there’s a Dunkin Donuts here with a drive-through between the building and the sidewalk (that’s novel but awful)

Touhy Avenue, Niles

This intersection may be the most urban, despite its immense size. Touhy has six lanes here meaning pedestrians must cross 100 feet of pavement in a faded, stamped-asphalt crosswalk; there’s a massive police station building on one corner, a large multi-unit building on another, a strip mall that actually has entrances onto a  sidewalk plaza instead of just in the parking lot behind it (the Subway and Starbucks here even have sidewalk cafés), and a fountain rounding out the junction – I recommend demolishing the fountain in favor of selling the land to a developer who can build more of the multi-unit buildings like the ones behind the fountain while also getting rid of the pointless cul-de-sac

Highland Avenue, Chicago

This is one block south of Devon Avenue, in Norwood Park. There’s a conventional bike lane here but the Chicago Department of Transportation has noted that there just enough cars that reducing the number of general purpose lanes from four to two – part of a road diet that would add buffered or protected bike lanes – but many residents don’t support the project so the alderman has decided against supporting it.

The land use and design is a blend of what came before it and what’s typical in Chicago: old buildings up against the sidewalk, closer-built single-family homes, some multi-unit buildings.

Austin Avenue, Chicago

Like Highland but now seeing fewer surface parking lots.

Central Avenue, Chicago

Like the rest of the junctions we’re still in motordom; four of the six “first in line” motorists seen in Google Streetview are blocking the crosswalk while waiting for the light to turn green.

About the stations

Pace has established a $6 million budget for the station construction. The station platforms will span 40 to 110 feet, a raised platform that’s 12 inches tall, a new shelter, real-time bus tracker*, a common vertical marker, a single bike rack to hold two bicycles, and associated roadway, curb, and drainage improvements.

It’s unfortunate to learn that the RFP mentions that shelters in Chicago may have to be the insufficiently designed kind JCDecaux operates for the city as part of a very long advertising contract.

Pace ART station design

Pace shows a rendering mocking up a typical station design. I’m concerned the handrail at the rear of the bus will preclude using longer buses in the future, but that would be the least of Pace’s worries.

* It appears that Pace will be using NextBus‘s real-time arrival information services (page A-6 of 14); they’re a company founded in 1996 and now owned by Cubic, which operates Ventra.

What if Metra employees were late to work as often as Metra passengers?

trainmageddon

A malfunctioning Metra Electric train in January. Photo by Eric Rogers.

It was a big deal to news media this morning when new Metra CEO Don Orseno reported at an Illinois House mass transit committee hearing that the commuter-focused rail system experienced a 30% on-time rating in January, when the “polar vortex” hit. (Apparently polar vortex is not an event that happens to a place, but is the name of a climate pattern that’s always there hovering above Canada and occasionally dips down over the United States.)

Most Metra passengers are commuters, going to work. A hair over 300,000 travel each weekday; service is drastically lowered on weekends and holidays, offering less than half the service of weekdays.

What if the organization of Metra, including all 2,500 employees in addition to the contracted railroad workers (let’s say 3,000 people), showed up to work with the same performance rating that their passengers experience?

First, Orseno – a career railroader who drives to work from Manhattan where a train comes leaves three times each day – would miss 11 work days of work each year (of 260 work days), based on their overall 95.8% on-time rating in 2012. Some routes are worse and others better. But collectively 3,000 people would miss 32,760 work days each year. That’s a lot of missed work.

Put another way, everybody – all 3,000 of them – is going to show up 20.16 minutes late to work because they’re missing 87.36 hours each year (of 2,080 hours they’re supposed to work and being 4.2% hours late). But again, I have no idea who’s working 8 hours and who’s working longer. (One of the problems Metra had during #Chiberia is that many workers hit the federally mandated limit and there weren’t always workers to take their place.)

Thankfully the Chicago Transit Authority, Pace, and ever-expanding highways and tollways are available to pick up the slack in Chicagoland’s transportation supply.

Another thing, this post is full of averages of averages, so it’s really imprecise. Today, Metra was reporting delays on a single train run of 16-100 minutes – a pretty broad estimate, but another train had a possible delay of 26-110 minutes. During the worst storm Metra experienced on January 5th and 6th, some train runs dumped passengers on platforms in subzero temperature.

Orseno reported today at the committee hearing that a “I don’t want to say middle-level” manager at Union Pacific made the call to dump the passengers. This has been “corrected” by only allowing a senior level staffer at Union Pacific make this call. Metra, which doesn’t have any performance-related incentives in its contracts with the freight railroads, apparently cannot stop this decision.

I’m waiting for the day when Metra is run like a transit system and not a railroad.

Note: I excluded vacation days because, well, no law requires organizations to offer paid or unpaid vacation days and there are probably several tiers of vacation-giving at Metra that I don’t know about.