2

I am trying to add a WMTS raster layer in QGIS 3.8 using Python (for my plugin).

I have found this Loading Layers - Raster in the documentation, but I cannot make it work.

I tried this:

QgsRasterLayer(f'url={url}&crs=EPSG:4326&format=image/png&tileMatrixSet=4326&username={name}&password={pwd}', 'some layer name', 'wmts').isValid()

But it returns False.

I see the same question asked a lot on this site, but no answer solves my problem.

How can I deal with this?

The URL works fine when I add the layer through the UI.

Other post : Loading a WMS layer to QGIS using python

6
  • 1
    should it not be f'url={url}?crs... or if url has a ? just f'url={url}crs... as per syntax key[=value]&
    – nmtoken
    Oct 24 '19 at 16:47
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Please check out our short tour to learn about our focussed Q&A format. If you have seen this question asked previously on this site then please provide links to those questions so that potential answerers do not have to retrace your steps.
    – PolyGeo
    Oct 24 '19 at 22:39
  • @nmtoken : unfortunaltly he question mark doesn't change the result. Oct 25 '19 at 7:26
  • @PolyGeo : Sure I edit the principal post. Oct 25 '19 at 7:28
  • Those previous questions all seem to be about WMS and you appear to be asking about WMTS. In any event most if not all of them look like they should be reviewed to see which are duplicates.
    – PolyGeo
    Oct 25 '19 at 8:15

Your Answer

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

Browse other questions tagged or ask your own question.