I have try a lot of PyQGIS lines codes to try to add any layer in WMTS from Geoservices using Python console in QGIS 3.34.
Geoservice site: https://geoservices.ign.fr/services-web-experts-ortho
Layer to add: BD ORTHO® 20 cm HR.ORTHOIMAGERY.ORTHOPHOTOS
URL: https://wxs.ign.fr/ortho/geoportail/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities
I have try:
qgis.utils.iface.addRasterLayer(
"tileMatrixSet=EPSG:3857&crs=EPSG:3857&layers=brtachtergrondkaart&styles=&format=image/jpeg&url=https://wxs.ign.fr/ortho/geoportail/wmts/HR.ORTHOIMAGERY.ORTHOPHOTOS", # uri
"wmts master example",
"wms"
)
But it is creating a corrupted layer.