Transit Inclusion & Exclusion

Tunneling through transit data

As any New Yorker will tell you, in 2019 the L will shut down between Manhattan and Brooklyn for a year and a half so the MTA can repair damage in the Canarsie Tunnel from Hurricane Sandy. Our friends at CARTO conducted a fantastic analysis last year on the impact of the shutdown. We’ve added some features to our Mobility API and the Mapzen Mobility Explorer that will make dynamic analysis of transit closures (as well as the addition of new lines) even easier to assess.

With the isochrone service in the Mobility Explorer, we can see the present level of service for the L from Bedford station in Brooklyn. You will notice that it takes a rider no more than 15 minutes to get to the 8th Ave station in Manhattan.

15min pic

(dark green, 15 minutes from stop. light green, 30 mins. purple, 45 mins. pink, 60 mins.)

We recently added include and exclude filters in the Valhalla API. You can filter transit agencies and routes in the Mobility Explorer and change the isochrone on the fly.

(For more granular control, you can use the Mobility API to filter individual stops from transit routing results and return isochrones as GeoJSON. Below, we exclude stations from 8th Ave. to Bedford Ave. that will be shut down when the Canarsie Tunnel closes in 2019.){"locations":[{"lat":40.7178,"lon":-73.9575}],"costing":"transit","contours":[{"time":5},{"time":15},{"time":30},{"time":45}],"polygons":true,"denoise":0.2,"generalize":150,"costing_options":{"transit":{"filters":{"stops":{"ids":["s-dr5rswb4zp-1av<l06n","s-dr5rsrhyn3-3av<l05n","s-dr5rsr9975-unionsq~14st<l03n","s-dr5ru0j0jv-6av<l02n","s-dr5ru02yqu-8av<l01n"],"action":"exclude"}}}}}

The commute time to the 8th Ave station (or most parts of Manhattan) will increase to 45 minutes during the L shutdown. As noted in the article, during each weekday 225K people will have an increased commute time for almost everywhere within Manhattan.

45min pic

(dark green, 15 minutes from stop. light green, 30 mins. purple, 45 mins. pink, 60 mins.)

You can investigate travel times excluding the L in Mapzen Mobility Explorer. Note that at the bottom of the left-hand column, you will see links to the API response for the Transitland and Mobility APIs that are used in Explorer queries. For the URLs that return GeoJSON, you can add them as a source in Tangram Play and draw transit lines stations and the isochrones together.

Exposing service improvements

The include feature can be used to show how things have gotten better after transit service was added.

Los Angeles’ Expo Line came online in May of 2016, providing service from Downtown Los Angeles to Santa Monica. You can now get from Santa Monica to downtown Los Angeles in just over an hour.

If we use our filters to exclude the Expo Line, we can see what the service was like before 2016.

Before the Expo line, it would take riders more than 2 hours to get east of downtown LA!

Note that this GIF shows isochrones in 30 minute contours, which is something that can be adjusted in the Isochrone API.

Our exclusion filter for the transit options would be as follows:


Customizing your route

Inclusion and exclusion can be used to all sorts of transit assessments. Let’s say you live in New Jersey and are heading to Manhattan to spend a day with the family. You only have a PATH SmartLink Card and don’t feel like purchasing another fare card for a different transit operator. Valhalla will now allow you to only return transit routes and stops that have service from your favorite transit operator!

In this scenario, all you have to do is request a transit route that only includes PATH. Our origin is Newark Penn Station and our destination is West 30th Street @ 8th Ave. We are leaving on the last Tuesday in the month @ 8:00 AM. Typically, this transit route will take service provided by Amtrak.

subway Enter the Newark Penn Station Amtrak Station. 227 m
subway Depart: 8:12 AM from Newark Penn Station Amtrak.

Take the Keystone Service toward New York Penn Station. (1 stop)

Arrive: 8:30 AM at New York Penn Station.
14.467 km
subway Exit the New York Penn Station. 52 m

But to keep that SmartLink card from burning a hole in your pocket, just reroute to only include/use the PATH operator.

subway Enter the Newark Station. 115 m
subway Depart: 8:06 AM from Newark.

Take the PATH toward World Trade Center. (3 stops)

Arrive: 8:21 AM at Grove Street.
11.009 km
subway Depart: 8:22 AM from Grove Street.

Transfer to take the PATH toward 33rd Street. (6 stops)

Arrive: 8:40 AM at 33rd Street.
6.021 km
subway Exit the 33rd Street Station. 1 m

How did we do it?

When a Valhalla tile is loaded into memory for a route, we populate three lists for including or excluding transit routes (stops, routes, and operators). Next, we added filters to the transit costing options so that a user can include or exclude as desired. Finally, when the multimodal algorithm is finding the best path, we determine if a stop, route, or operator should be excluded from the path. Everything, is filtered by Transitland’s Onestop IDs which are assigned during the transit import process.

How to obtain Onestop IDs for inclusion and exclusion?

  • Valhalla - Onestop IDs can be obtained by running a transit route and parsing the returned JSON maneuver transit_info to obtain operator_onestop_id and the route onestop_id. A transit_stop contains the onestop_id for the stop.
  • Mobility Explorer - Onestop IDs can be obtained by selecting a single route, stop, or operator by clicking on it on the map. For routes and operators, you may also select by choosing from the drop-down menu in the sidebar. The Onestop ID will then be provided in the sidebar, along with other detailed information about the route, stop or operator you have chosen. More information can be found in the Mobility Explorer documentation.
  • Transitland - The Transitland Datastore API can be used to directly query for stops, routes, and operators using a number of options. For example, filtering for only subway routes or bus routes. Please see the Transitland Datastore API documentation for more details.

New Filter Costing Options.

New Transit option Description
filters Filters are used to include or exclude certain stops, routes, and operators. Filters must contain a list of Onestop IDs and an action.
  • filters (one or many can be used)
    • stops
    • routes
    • operators
  • ids - any number of Onestop IDs (e.g., o-9q9-bart)
  • action
    • exclude - exclude all of the ids listed in the filter
    • include - include only the ids listed in the filter
Filters example - "costing_options":{"transit":{"filters":{"stops":{"ids":["s-dr5rsq8pqg-8st~nyu<r21n","s-dr5rsr9wyg-14st~unionsq<r20n"],"action":"exclude"},"routes":{"ids":["r-dr5r-r"],"action":"exclude"},"operators":{"ids":["o-dr5r-path"],"action":"include"}}}}

Using our example from New Jersey to Manhattan, our filter would look like this to only use PATH as our operator.


Excluding & including in a city near you

Mapzen’s motto is “start where you are”, so if you see ways to improve our multimodal routing please let us know. Also, have a look at our documentation to see the structure of the API request and response and sign up for a free developer key to start using Mapzen Turn-by-Turn.

Please help expand Transitland’s coverage by contributing feeds to the Feed Registry. In the coming months, we’ll be ingesting even more of these feeds into Turn-by-Turn. To see which transit operators are routable, follow this link to a filtered view of the Feed Registry. As always, should you have any questions, write to us at