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
Raphael BahuauRaphael Bahuau
asked Oct 24, 2019 at 12:58
lang-py
f'url={url}?crs...
or if url has a ? justf'url={url}crs...
as per syntaxkey[=value]&