Working with vector tiles - Part 1

JUNE 10, 2020 qgis vectortiles

After a successful crowdfunding campaign to support Vector Tiles in QGIS, we have been busy adding new features for the upcoming release (3.14).

In this blog post, we are exploring different methods to add your vector tiles and style them.

Loading data - local files

If you have an MBTiles file containing vector tiles, you can simply drag and drop the layer in QGIS. Alternatively, you can connect to a local vector tile file(s) from the Data Source Manager or the Browser Panel. As an example, you can use this QGIS project which contains Switzerland vector tiles (maximum zoom level =14).

Vector tile file

You can also test this project on your mobile device. Download Input app (for iOS you need the TestFlight version of the app), head to Projects > Explore and download saber\blogpost-vectortile.

Loading data - web resources

You can access vector tiles served through the web. You need to have the URL and possibly API key to add them in your QGIS. In the example below, vector tiles from MapTiler are added to QGIS:

Vector tile file

To use MapTiler data, we recommend using their dedicated QGIS plugin, which comes with vector tiles in different styles. The plugin should be available on the QGIS plugin repository.

Styling data

Vector tiles contain points, line and polygon geometries. You can define a set of rules for features and apply style and label. Style and labelling can be dependent on the zoom level. Similar to vectors and rasters, styles for vector tiles can be stored in QML format. To set up filters, you can use the identify tool in QGIS to inspect geometries of your vector tile:

Vector tile file

Currently, the most common format to store vector tiles styles are Mapbox GL (json). The OpenMapTiles repo contains some excellent Mapbox GL styles. We initially developed a tool to convert the json files to QGIS style. The plugin has been further extended and developed by MapTiler to better handle the OpenMapTiles data schema. This will ensure future changes to the data schema will be addressed by the plugin.

Example of styles converted from Mapbox GL to QGIS from Maptiler QGIS plugin

Vector tile file

Vector tile file

Vector tile file

Vector tile file

In the next post, we will explore different options within QGIS or other 3rd party tools to generate vector tiles.

Credits

All the data used in this blog post was from OpenStreetMap server by Geofabrik. OpenMapTiles conversion tool was used to generate the tiles from OpenStreetMap to vector tiles. See software license for more details.

The following OpenMapTiles Mapbox GL styles Bright, Positron, Basic and Fiord were converted using mapbox2qgis and QGIS MapTiler plugin.


Posted by Martin Dobias, Saber Razmjooei