Integrating a WMTS raster tile service in QGis 3 and Felt

What is WMTS? A good example of a WMTS service is OpenStreetMap. It consists of an address to which client programs can request geotagged images. When you load OSM into QGis, the program connects to the OSM server and asks it for the images needed to fill your map window.

There are two types of geolocalized image services: WMS and WMTS.

Web Map Service (WMS): this is an OGC web service standard that allows the dynamic production of maps from georeferenced images; the server is then requested to generate an image corresponding to the requested window,

Web Map Tiled Service (WMTS): this is a standard describing how to distribute map data in the form of predefined tiles. The client specifies a standard zoom level and the tiles available to fill the requested window are sent. Compared to WMS, the main advantage of WMTS is that it offers better performance in map data delivery, as the tiles are cached during the first generation.

There are more and more WMTS services available for the general public. If OpenStreetMap is one of the most used because it is available by default in the QGis interface, if you load the Quick Map services plugin, you will have a long list of services available directly on QGis. As far as Felt is concerned, you will have by default only Mapbox and Stamen.

But whether it is Qgis or Felt, you can integrate the WMTS service of your choice, provided that it respects a certain communication format called {xyz}.

The {XYZ} format

The xyz services obey a standard on how tiles should be requested based on 2 concepts: zoom levels and tile coordinates.

The zoom levels define the scale of the map. At zoom level 0, an entire Mercator projection of the earth is contained in a 256px by 256px tile:

At each additional zoom level, the number of tiles increases by a factor of four and the spatial resolution (meters on the ground per pixel) of each tile approximately doubles.

The highest zoom level (Z) depends on the application, at zoom level 15 there are over a billion tiles each with a spatial resolution of 4.77 meters per pixel. Here is an example of a Z15 tile from Open Street Map.

At any given zoom level, a specific tile can be identified by Cartesian (XY) coordinates with 0.0 starting at the top left of the map.

URL format

The structure of a typical {XYZ} tile request looks like this:

url/zoom-level/x-coordinate/y-coordinate.png

And here is an example that we will follow in this article

{z}/{x}/{y}.png

This is the line that needs to be entered in QGis or Felt to add the EDMOnet WMTS service.

{Z}, the zoom level, {x} and {y} the coordinates of the requested tiles, are variables that the requesting software (QGis or Felt ) will fill in according to the displayed map. Everything else (tiles.emodnet-bathymetry.eu/2020/baselayer/web_mercator/) is the URL to access the tiles.

Where can I find the URL of a tile server?

For some servers, it’s easy. For OpenStreetMap, on the page https://wiki.openstreetmap.org/wiki/Raster_tile_providers you find the urls to use for the different maps available

Be careful to remove the $ sign in front of x,y, and z when you fill in the url in a software.

But, unfortunately, it is often a bit more complicated. Let’s take our EDMOnet world bathymetry. When you go to the page with the WMTS products you have a list:

You have a URL link corresponding to the server’s GetCapabilities. This XML page is mandatory for any WMTS server, and lists all the service features as well as the URL(s) available for the tiles. Unfortunately, it is in XML language and not a common language. We’ll have to decrypt it to find our desired URL.

Decrypting the Getcapabilities of a WMTS server

We start by copying and pasting the getcapabilities url on our browser. For the bathymetry it is

https://tiles.emodnet-bathymetry.eu/wmts/1.0.0/WMTSCapabilities.xml

We then get the requested XML page

The page is hundreds of lines long. But let’s look at what we are interested in: look for the text ResourceURL format in the page

You have there the url model to use:

tiles.emodnet-bathymetry.eu/2020/baselayer/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png

As for {TileMatrix}/{TileCol}/{TileRow}, no problem, you just replace them with {z}/{x}/{y}. But there is another variable, {TileMatrixSet}, that you will have to fill in hard in your URL. To find out what the possible values are, in the text search window on the page, enter and look for the previous occurrence (^). You will find the different values this variable can take:

These are the different projection systems that are available. Apart from inspire_quad which is an invention of lUE, the other systems are all managed by Qis and Felt. You can choose any of them, but if you want to stay in the classic, web_mercator will do well. So we have our URL made up as follows:

tiles.emodnet-bathymetry.eu/2020/baselayer/web_mercator/{z}/{x}/{y}.png

If you find other variables on the URL template, follow the same procedure to find the accepted values. You will need to replace all variables other than {z}/{x}/{y} with a value of your choice.

Add the tile server in QGis

In the Explorer panel right click on XYZ Tiles -> New connection

Give a name to your connection and in Connection details enter the url

You will have EMODNet on the list of tile servers and you can load it directly into your project.

Add the tile server in Felt

In Felt you can load the tile server as a background.

Click on the Change Background button at the bottom of the map, then on the + sign (Add Background)

Select the From URL tab, give your connection a name (Title) and enter the URL in the Tile URL field

As soon as you enter the URL, you should see an extract of the layer in the Preview box. If not, your URL has an error.

Click on Add Background and you will have the new map background on your map.

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *