Guide

Vector tiles and terrain in QGIS

QGIS reads vector tiles with a MapLibre style and draws them as a base map, and it reads Terrain-RGB tiles as heights. The connections, the styles QGIS converts well, terrain as an elevation raster, and contour lines. Tested with QGIS 4.2.3.

Layer › Add Layer › Add Vector Tile Layer…, then New › New Generic Connection…:
Name:            overpass.ch light
URL:             https://api.overpass.ch/v1/YOUR_KEY/maps/vector/{z}/{x}/{y}.mvt
Min. Zoom Level: 0
Max. Zoom Level: 14
Style URL:       https://api.overpass.ch/v1/YOUR_KEY/maps/styles/light.json
Click OK, select the connection and click Add.

The vector tile connection

  1. Open Layer › Add Layer › Add Vector Tile Layer… (or the Data Source Manager, tab Vector Tile).
  2. Click New and choose New Generic Connection….
  3. Enter the values above. Keep {z}/{x}/{y} as written; QGIS fills it in.
  4. Max. Zoom Level 14 tells QGIS to enlarge zoom 14 closer in. With a higher value, QGIS asks for zoom 15 and above, which do not exist (HTTP 404).
  5. Style URL makes QGIS convert our MapLibre style into QGIS symbols and labels. Without it, QGIS draws every layer in one default style.

In our test, QGIS converted the light style into 60 symbol rules with labels, with no warnings. The connection is saved in your profile and shows in the Browser panel under Vector Tiles.

Which styles work

QGIS draws the layers of a style that come from the vector tiles named in the URL field. Layers from other sources of the style are left out:

StyleIn QGIS
light, dark, white, grayscale, black, drivingLand use, water, roads, railways, buildings and borders, as in the browser.
outdoorThe base map with paths and huts. The graded trails, contour lines and hillshading come from other sources and are missing.
reliefRoads, water and glaciers on grey land. The colours by height, hillshading and contour lines are missing.
marineThe land, the coast and ferry routes on a plain blue sea. Depths, depth contours and sea marks are missing.

In our test QGIS showed road numbers, but not the names of places and streets. For a print or an analysis, start with one of the first six styles, add terrain and contour lines as layers of their own, below, and names from OpenStreetMap with QuickOSM if you need them.

Terrain as heights

Our terrain tiles store the height in the colour of each pixel, in the Mapbox Terrain-RGB encoding. QGIS decodes it into a height raster: Layer › Add Layer › Add XYZ Layer…, then New:

Name:            overpass.ch terrain
URL:             https://api.overpass.ch/v1/YOUR_KEY/maps/terrain/{z}/{x}/{y}.png
Min. Zoom Level: 0
Max. Zoom Level: 10
Tile Resolution: High (512x512 / 192 DPI)
Interpretation:  MapTiler Terrain RGB

MapTiler Terrain RGB uses the same formula as the Mapbox encoding. The layer then has one band of heights in metres: in our test it read 1,606.3 m in Zermatt and 4,210.5 m on the Matterhorn, which is what the 90 m Copernicus data gives there. Set its renderer to Hillshade for shading under the vector layer, use it for the elevation of the 3D map view, or sample it with the raster tools.

Contour lines

Add the contour lines as a second vector tile connection, without a style URL:

Name:            overpass.ch contours
URL:             https://api.overpass.ch/v1/YOUR_KEY/maps/contours/{z}/{x}/{y}.mvt
Min. Zoom Level: 10
Max. Zoom Level: 14

The layer contours has the fields ele (metres) and level (1 on every fifth line). Style it in the layer properties: a thin brown line, a thicker one for "level" = 1, and labels from ele. They show from zoom 10, about 1:500,000. With the terrain raster above, QGIS can also compute contour lines at other intervals (Raster › Extraction › Contour).

Key and referer

  • QGIS sends no referer. Use a key without a website restriction, or enter one of the allowed websites of your key in the Referer field of the connection.
  • Your key is saved in the connection. Share a QGIS project file only with people who may use your key, or use one key for each of them.
  • Every vector, terrain and contour tile counts as one map tile. Every account includes 100'000 tiles a month.
  • The terms do not allow bulk downloads of tiles, such as seeding a whole country into a cache or an MBTiles file. For offline work over a large area, use the whole-world file that Protomaps publishes.