3

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

asked Oct 24, 2019 at 12:58
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]& Commented Oct 24, 2019 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. Commented Oct 24, 2019 at 22:39
  • @nmtoken : unfortunaltly he question mark doesn't change the result. Commented Oct 25, 2019 at 7:26
  • @PolyGeo : Sure I edit the principal post. Commented Oct 25, 2019 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. Commented Oct 25, 2019 at 8:15

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.