I have an OpenLayers map with EPSG:3857 projection. I would like to add WMTS layer http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/ORTO which support only matrix for EPSG:2180 and 4326.

Is any way to reproject this WMTS layer?

I was trying with this code but the layer is shown in wrong place.

    var WMTS2 = new ol.layer.Tile({
                    opacity: 0.5,
                    extent: projectionExtent,
                    source: new ol.source.WMTS({
                        url: 'http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/ORTO',
                        layer: 'ORTOFOTOMAPA',
                        matrixSet: '2180',
                        format: 'image/jpeg',
                        projection: 'EPSG:2180',
                        tileGrid: new ol.tilegrid.WMTS({
                            origin: ol.extent.getTopLeft(projectionExtent),
                            resolutions: resolutions,
                            matrixIds: matrixIds
                        extent: projectionExtent,
                        style: 'default'
  • You might have a go looking here Openlayers site
    – cm1
    Aug 22, 2018 at 15:48
  • I used this metod above, but I don't know how Matrix reproject. The layers is placed in a wrong place on map.
    – Lukasz
    Aug 23, 2018 at 9:51

1 Answer 1


I tried setting that up using ol.source.WMTS.optionsFromCapabilities but it didn't work because the GetCapabilities lists the TopLeftCorner as 850000.0 100000.0 which is somewhere in Ukraine. However I suspected the x and y were reversed and used the matrixIds, resolutions and tileSize returned by optionsFromCapabilities but changed the origin: [850000, 100000] to [100000, 850000] and it worked:

              tileGrid: new ol.tilegrid.WMTS({
                  origin: [100000, 850000],
                  matrixIds: ["EPSG:2180:0",
                 resolutions: [2116.6709,
                 tileSize: 512

enter image description here

  • The service works fine for me in QGIS using either EPSG:2180 or EPSG:4326, so it doesn't look like coordinates are flipped. For EPSG:2180 x axis is Northing (epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::2180) and for EPSG:4326 x axis is latitiude (epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4326)
    – nmtoken
    Dec 6, 2018 at 9:28
  • Those definitions won't work with OpenLayers. In OpenLayers EPSG:4326 is predefined as LonLat, all other projections except EPSG:3857 require proj4 and are x, y unless the proj4 definition specifies "+axis=neu", which it doesn't epsg.io/2180. Depending on your opinion either OpenLayers, the proj4 definition, or the WMTS service are incompatible. There are similar issues with EPSG:31254.
    – Mike
    Dec 6, 2018 at 10:40
  • OpenLayers has it wrong then. OpenLayers can't define the axes order for EPSG projections, only EPSG can do that.
    – nmtoken
    Dec 6, 2018 at 12:10
  • epsg.io is not the official registry of EPSG codes, you can't use it as the definitive source of axes order, you have to go to epsg-registry.org
    – nmtoken
    Dec 6, 2018 at 12:14
  • 1
    Now I have seen the correct WKT for 2180 it's clear the WMTS service isn't incorrect, but it inconsistent with OpenLayers. Somewhere in the code will be a proj4 definition string which defaults to enu so OL does honour the correct axes order which it has been given, so neither is OpenLayers incorrect there. Either the proj4 definition needs to be updated, or the matrix origin needs to be specified in the x, y format. In this case option 2 was easier..
    – Mike
    Dec 6, 2018 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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