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:
- show all of the different variants of the route (all of the possible trip geometries)
- provide a single geometry that can be understood on its or on a map with many other routes
- not be too large in file size
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:
- for each route direction:
- select the longest shape
- select any shape used for at least 20% of trips
- from this collection, drop shapes with totally broken geometry, e.g. a point at (0,0)
- drop shapes contained entirely within another selected shape
- include generated stop-to-stop geometries only if no
shapes.txt
shapes are available - combine the selected shapes into a representative
MultiLineString
- 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:
- routes shapes that travel to Null Island (include a 0,0 point)
- routes shapes that zigzag between stop locations out of order
- route shapes that have not been updated to reflect current stop locations and sequence
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:
- Shape length greater than 5,000km
- Any individual line segment above 50km for
shapes.txt
geometries - Any individual line segment above 5km for generated stop-to-stop geometries
- "Zigzag" shapes where points are in obviously incorrect order
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 level | Feature(s) | Level of detail |
---|---|---|
0 | single LineString | geometry simplified for display at given zoom level |
1 | single LineString | geometry simplified for display at given zoom level |
2 | single LineString | geometry simplified for display at given zoom level |
3 | single LineString | geometry simplified for display at given zoom level |
4 | single LineString | geometry simplified for display at given zoom level |
5 | single LineString | geometry simplified for display at given zoom level |
6 | single LineString | geometry simplified for display at given zoom level |
7 | single LineString | geometry simplified for display at given zoom level |
8 | full MultiLineString | geometry simplified for display at given zoom level |
9 | full MultiLineString | geometry simplified for display at given zoom level |
10 | full MultiLineString | geometry simplified for display at given zoom level |
11 | full MultiLineString | geometry simplified for display at given zoom level |
12 | full MultiLineString | geometry simplified for display at given zoom level |
13 | full MultiLineString | geometry simplified for display at given zoom level |
14 | full MultiLineString | full 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:
- If you have not already, download and install the QGIS desktop GIS software package.
- If you have not already, sign up for a Transitland API key.
- From the menu, select Layer > Add Layer > Add Vector Tile Layer...
- Press the New button and select New Generic Connection...
- Enter "Transitland stops" or "Transitland routes" at the name (or whatever you wish)
- For URL, enter
https://transit.land/api/v2/tiles/routes/tiles/{z}/{x}/{y}.pbf?apikey=xxx
orhttps://transit.land/api/v2/tiles/stops/tiles/{z}/{x}/{y}.pbf?apikey=xxx
You will need to replacexxx
with your own API key - Press the OK button
- 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
- 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.
- Customize the styling for one or both of the layers.
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.