I have the URL of a WMTS server which provides map tiles in EPSG:25832 (ETRS89 / UTM zone 32N; I'm sorry I cannot post it as it contains user credentials).

If I connect to this server with QGIS I can select a tileset (ADV_25832_Quad) and it is displayed properly. The image below (left) shows the result with a vector layer (red border) for verification.

Now I tried to use this WMTS server in OpenLayers by combining these two examples:

In OpenLayers the WMTS layer is not displayed properly (see image below on the right).

I think is has to to with the projection extent or the resolution of the tilegrid (I got the projection extent from https://epsg.io/25832).

But how does QGIS get these values and how can I get them for OpenLayers?

Here's my code:

var projectionName = 'EPSG:25832';
proj4.defs(projectionName, '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var projection = ol.proj.get(projectionName);

var projectionExtent = [ -1877994.66, 3932281.56, 836715.13, 9440581.95 ];
var size = ol.extent.getWidth(projectionExtent) / 256;
var resolutions = new Array(14);
var matrixIds = new Array(14);
for (var z = 0; z < 14; ++z) {
    resolutions[z] = size / Math.pow(2, z);
    matrixIds[z] = "ADV_25832_Quad:" + z;

var map = new ol.Map({
    layers: [
        new ol.layer.Tile({
            opacity: 1,
            source: new ol.source.WMTS({
                attributions: '...',
                url: 'https://...',
                layer: "DOP_20_C",
                "matrixSet": "ADV_25832_Quad",
                projection: projection,
                tileGrid: new ol.tilegrid.WMTS({
                    origin: ol.extent.getTopLeft(projectionExtent),
                    resolutions: resolutions,
                    matrixIds: matrixIds
                style: 'default',
                wrapX: true,

        new ol.layer.Vector({
            source: new ol.source.Vector({
                url: 'bw25832.txt',
                format: new ol.format.GeoJSON()
            style: new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: 'red',
                    width: 2

        target: 'map',
        view: new ol.View({
            projection: projection,
            center: [506102,5384251],
            zoom: 8

WMTS in QGIS / OpenLayers


Here are the top 2 levels of the tile matrix from the getCapabilities response:

                    <TopLeftCorner>-46133.17 6301219.54</TopLeftCorner>
                    <TopLeftCorner>-46133.17 6301219.54</TopLeftCorner>
  • can you add the first couple of levels of tilematrix from the capabililities document
    – Ian Turton
    Commented Oct 2, 2018 at 8:34
  • GetCapabilities: pastebin.com/RRVmX9Ms
    – Mark
    Commented Oct 2, 2018 at 8:55

1 Answer 1



The easy way to do this is to ask OpenLayers to read the capabilities document in the same way that QGIS does - see this example.


As you can see the tile matrix origin for the top level in the capabilities document (which is what QGIS uses) doesn't match the one that you are using in OpenLayers, this is why your tiles are in the wrong place.

<TopLeftCorner > 6104500.7393 3386564.94 </ TopLeftCorner >

var projectionExtent = [ -1877994.66, 3932281.56, 836715.13, 9440581.95 ];

You will need to change the origin and extent of the OpenLayers resolutions to match the size of your image or change your grid set to match the size of the CRS that you are using in OpenLayers.


You must also match the scales/resolutions or the image will be drawn at the wrong scale. Remember that resolution is size*1/ScaleDenominator when calculating,

  • Thank you! I edited your edit for matrix ADV_25832_Quad (instead of ADV_31467_Quad). I changed projectionExtent to the one provided in the QGIS layer properties (386534.8375906916335225, 5257236.4518752954900265, 625544.8511655556503683, 5518231.0112389167770743). Now it looks like this: i.imgur.com/bbc2FNM.png
    – Mark
    Commented Oct 2, 2018 at 9:16
  • you need to match the scales too
    – Ian Turton
    Commented Oct 2, 2018 at 9:17
  • OK, how do I get these?
    – Mark
    Commented Oct 2, 2018 at 9:30
  • from the caps file too
    – Ian Turton
    Commented Oct 2, 2018 at 9:31
  • You mean the ScaleDenominator values?
    – Mark
    Commented Oct 2, 2018 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.