I'm trying to write a python script to load the Environment Agency (EA) Flood Zones WMS layers into QGIS (2.14). I've provided a link to the EA's data catalogue at the bottom of this question. The layers I'm hoping to use from the catalogue are "Flood Map for Planning (Rivers and Sea) - Flood Zone 2" and "Flood Map for Planning (Rivers and Sea) - Flood Zone 3".
I have used the code below, copied from a similar question (link at the bottom), but rlayer.isValid() is always returned as False no matter how I edit the url. I can take the url in the example code below and manually add the WMS layers with no issues.
Am I missing something in my url? Or is the issue somewhere else?
Extract from my code:
urlWithParams = 'url=http://www.geostore.com/OGC/OGCInterface?SESSIONID=-2049535737&INTERFACE=ENVIRONMENT&version=1.3.0&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=eainspire2011-wms-nat_floodzone2_inspire&format=image/png&STYLE=default' rlayer = QgsRasterLayer(urlWithParams, 'EA Flood Zone 2', 'wms') rlayer.isValid() QgsMapLayerRegistry.instance().addMapLayer(rlayer)
For anyone wondering the correct working links are below:
EA Flood Zone for Planning - Zone 2: http://environment.data.gov.uk/ds/wms?INTERFACE%3DENVIRONMENT--86ec354f-d465-11e4-b09e-f0def148f590
EA Flood Zone for Planning - Zone 3: http://environment.data.gov.uk/ds/wms?INTERFACE%3DENVIRONMENT--87446770-d465-11e4-b97a-f0def148f590