in Geomatics

Easily add custom tilemap layers in QGIS

QGIS is growing fast and is considered by many as a valid (or even superior) alternative to ESRI’s ArcGIS. In one of my previous posts I described how to use GDAL xml-files to simply add baselayers of different sources (WMS/TMS). With QGIS 2.18 Las Palmas, a new feature has been introduced that natively allows to add tilemap layers.

Step-by-step guide

To show you how simple it is to add tilemap layers to QGIS I will use the example of OpenTopoMap (a layer that was asked for in the comments of my previous post).

1. Find your tilemap URL

Normally this URL contains at least placeholder for x, y and z. In the example of opentopomap, a quick google search guides me to the OpenTopoMap page on the OpenStreetmap wiki.
The last paragraph shows how OpenTopoMap can be used:

{a|b|c}.tile.opentopomap.org/{z}/{x}/{y}.png

Within this URL, the highlighted parts have the following function:
{a|b|c} specifies that one of three servers shall be used. (either a.tile.opentopomap.org, b.tile.opentopomap.org or c.tile.opentopomap.org)
{z} sets the zoom-level for which the tile is requested. The more we zoom in, the more tiles we get.
{x}/{y} indicate which tile is loaded. Values normally refer to the tile number form an origin point.

2. Activate the browser panel

Look for the browser panel in the QGIS interface. If not open yet, you can add it by going into the “view” menu > “panels” > “Browser panel”.

3. Add your service as a tilemap server to QGIS

In your browser panel scroll down and make a right click on “Tile Server (XYZ)”. A context menu will open that allows you to create a new connection.

Selecting this function will bring up a window that allows us to enter the previously found URL for our service.

You see in my example that I selected one of the three options for the server and added the “http://”-prefix to complete the URL.

4. Add the layer to your project

Now that you service appears in your list of tilemap server you can now double-click it to add the layer to your project.

Troubleshooting

  • Remember that tilemap tiles are loaded on-demand and require an internet connection. If you have a slow connection it can happen that the layer is not loaded successfully.
  • In cases where alternative options are given for the tilemap server (i.e. like {a|b|c} with OpenTopoMap) you can always switch to another server to see if that leads to more success.
  • If you want to test if the server is responding, just copy the URL into your browser and replace the placeholders with actual values (i.e. http://c.tile.opentopomap.org/3/2/5.png). If this shows you a single tile, the tilemap server is operating normally.

Conclusion

What does that mean for you? From now on any time you stumble upon a reference to a URL that includes the {x}/{y}/{z} triplet, you can directly add this to your tilemap collection.

Do you have any favorite sources? Share them in the comments below…

Write a Comment

Comment

  1. Do you have any suggestions for accessing tiles stored locally on disk? I tried both file:///path/to/tiles/{z}/{x}/{y}.png and /path/to/tiles/{z}/{x}/{y}.png without success in QGIS but it does work in OpenLayers.

    • Interesting question… unfortunatley after some first quick trials I failed as well. Will have to investigate a bit further – but please let me know if you find a solution…

  2. Below are a couple more tile connections I have tried that are handy. I am a semi-retired student at the Bay College community college and I am trying to promote Opensource GIS here at the lab. This is my first post ever so let me know if these work for you. I cut and pasted them from my notes in “Cherry Tree”. I noticed the actual URL’s are hard to lift from the XYZ tile server connections themselves when looking at their properties because of the goofy formatting. Is this because or the brackets? I am new to this stuff.

    Some example URLs

    OpenStreetMap
    http://tile.openstreetmap.org/{z}/{x}/{y}.png

    Google Hybrid
    https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}

    Google Satellite
    https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}

    Google Road
    https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}
    (Codes for other tile types from Google found here)

    Bing Aerial
    http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1

    Esri tiles below
    http://services.arcgisonline.com/ArcGis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png

    Open Topo
    http://c.tile.opentopomap.org/{z}/{x}/{y}.png

  3. Is there still no solution for using tiles stored locally on disk? We’re working on QGIS-Server for hosting cached rasterfiles. For this we generated tiles with QTiles- Plugin, which worked really well. But we haven’t found a solution to include them in our project yet. Consequently we’re not able to build a cached WMS. Maybe you’ve some hints?

    • This is something that I always wanted to test, but have not found the time to investigate. It would also require actually downloading all the tiles to disk first.

Webmentions

  • Amsterdam City Tiles – Amsterdam Time Machine 4. May 2022

    […] Tiles are also easily imported in geojson.io (Meta > Add map layer, paste the tile layer url and give it a name) and QGIS (see how). […]