I'm using the following code to load a WMS layer to QGIS :
url = "https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=normal&FORMAT=image/geotiff&LAYERS=ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES&CRS=EPSG:2154&WIDTH=2000&HEIGHT=2000&BBOX="
layer_name = "RGE ALTI"
provider = "wms"
layers = QgsProject.instance().mapLayersByName('bbox')
layer = layers[0]
extent = layer.extent()
bbox_shp = f'{extent.xMinimum()},{extent.yMinimum()},{extent.xMaximum()},{extent.yMaximum()}'
url += bbox_shp
layer = QgsRasterLayer(url, layer_name, provider)
if layer.isValid():
QgsProject.instance().addMapLayer(layer)
print("Layer added successfully!")
else:
print("Failed to load layer.")
The layer doesn't load, but when I copy paste the url in a browser, I am able to download the corresponding layer. Anyone has had a similar problem ? N.B : There is no problem with the bounding box shapefile
Edit: I've added the "url=" as mentioned in Loading WMS layer to QGIS using Python, however this does not fix the issue