Transitland · · 5 min read

Transitland Vector Tile Improvements

Since releasing the global transit map and v2 Vector Tiles API last year, we've added a variety of improvements in functionality and in rendering.

Transitland's global transit map provides a worldwide view of public bus, train, subway, ferry, and gondola route lines and stop points around the world. Using the v2 Vector Tiles API developers can integrate Transitland routes and stops tiles into their own web maps.

Since releasing the global transit map and v2 Vector Tiles API last year, we've added a variety of improvements in functionality and in rendering.

Performance Improvements

The Transitland global transit map and v2 Vector Tiles API are based on tiles in the MVT (Mapbox Vector Tile) format. We've made a number of changes to the data that's encoded into each MVT tile for route geometries. The changes are small but add up to a meaningful decrease in the size of the tiles and an increase in rendering performance. These improvements are especially useful at zoomed out (small scale) views:

Representative Route Geometries

While some transit routes are simple, with all trips following the same line, other transit routes can be very complicated. Routes may have trips along certain lines at peak hours and along other lines at off-hours. Routes may branch and go in multiple directions depending upon the trip. Many different combinations are possible all under the same branding of a single route name.

Transitland creates "representative" route geometries for every route. This geometry must balance competing goals:

When a source feed does not provide shapes.txt for a given trip, Transitland generates "stop-to-stop geometries" by drawing straight lines between stop locations.

The representative geometry for each route is created using the following rules:

  1. for each route direction:
    • select the longest shape
    • select any shape used for at least 20% of trips
  2. from this collection, drop shapes with totally broken geometry, e.g. a point at (0,0)
  3. drop shapes contained entirely within another selected shape
  4. include generated stop-to-stop geometries only if no shapes.txt shapes are available
  5. combine the selected shapes into a representative MultiLineString
  6. the single most frequently used shape becomes the representative LineString

Problematic Route Geometries

Creating high quality shapes.txt records in GTFS feeds can be a challenge. Occasionally agencies do make mistakes. For example:

Transitland's goal when importing from shapes.txt is the same as our overall goal with GTFS source feeds: We aim to import as many records as possible, while ignoring records that are invalid or that are of such low quality that they will not be usable. Transitland continues to import the overall feed, even if it must leave out some records.

(Transitland's import strategy is in contrast with validators and tooling that are used by agencies when generating GTFS — for those types of use-cases, the user may wish to have the process fail an entire feed when one of its entities causes a problem. The operator will then fix the feed before repeating the validation process.)

Transitland tags as problematic route geometries that fit the following criteria:

Problematic geometries are still included in the MVT vector tile data, but the global transit map hides these geometries by default. To see them, open Options and select Show problematic route geometries:

Two tiers of feature detail

A typical tile set contains over 150,000 routes! This can be expensive to load and render at low zoom levels, so some compromises are baked into the tiles. Vector tile zoom levels 8 and higher include the full MultiLineString representative geometries and all route features. Tile zoom levels between 0 and 7 include a single LineString geometry for each route, and on particularly dense tiles, a percentage of route features are dropped to help manage the file size of each tile (routes with high levels of service are weighted towards inclusion). Zoom levels 0 to 13 include line simplification appropriate for displaying at that zoom level; zoom level 14 includes the full, unsimplified geometry.

Zoom levelFeature(s)Level of detail
0single LineStringgeometry simplified for display at given zoom level
1single LineStringgeometry simplified for display at given zoom level
2single LineStringgeometry simplified for display at given zoom level
3single LineStringgeometry simplified for display at given zoom level
4single LineStringgeometry simplified for display at given zoom level
5single LineStringgeometry simplified for display at given zoom level
6single LineStringgeometry simplified for display at given zoom level
7single LineStringgeometry simplified for display at given zoom level
8full MultiLineStringgeometry simplified for display at given zoom level
9full MultiLineStringgeometry simplified for display at given zoom level
10full MultiLineStringgeometry simplified for display at given zoom level
11full MultiLineStringgeometry simplified for display at given zoom level
12full MultiLineStringgeometry simplified for display at given zoom level
13full MultiLineStringgeometry simplified for display at given zoom level
14full MultiLineStringfull unsimplified geometry

Use Transitland v2 Vector Tiles API in QGIS

Can you use Transitland vector tiles in desktop GIS software? Thanks to a curious user for asking this question. Turns out the answer is yes.

If you want to use Transitland route lines and stop locations as layers in your own GIS map, along with your other data sources, here are instructions for how to do so in QGIS:

  1. If you have not already, download and install the QGIS desktop GIS software package.
  2. If you have not already, sign up for a Transitland API key.
  3. From the menu, select Layer > Add Layer > Add Vector Tile Layer...
  4. Press the New button and select New Generic Connection...
  5. Enter "Transitland stops" or "Transitland routes" at the name (or whatever you wish)
  6. For URL, enter https://transit.land/api/v2/tiles/routes/tiles/{z}/{x}/{y}.pbf?apikey=xxx or https://transit.land/api/v2/tiles/stops/tiles/{z}/{x}/{y}.pbf?apikey=xxx You will need to replace xxx with your own API key
  7. Press the OK button
  8. In the Browserside menu, you will now see the new source listed under Vector Tiles. Right click on it and select Add Layer to Project
  9. You should now see the layer visualized. Repeat the steps to add the other layer, if you wish to have both stop points and route lines.
  10. Customize the styling for one or both of the layers.
screenshot of QGIS desktop GIS software displaying Transitland vector tiles

Please note that the Transitland terms require that you provide attribution on maps and other creations using output from the Transitland APIs.

We look forward to seeing what GIS users, software developers, and data analysts create using these enhanced transit map tiles. We welcome all to post their creations on Transitland's "show and tell" discussion board.

Read next

How current is that schedule?
Transitland ·

How current is that schedule?

The GTFS Best Practices guide recommends publishing data for the current data plus at least 7 days in the future. We've used the Transitland archives to assess how many feeds meet this goal.