[Qgis-developer] Problem with sub-layer visibility in WMS raster layer
Richard Burkmar
rich.burkmar at gmail.com
Wed Nov 5 04:11:43 PST 2014
I'm trying to solve a problem involving a change to QGIS handling of the
setSubLayerVisibility method for a WMS layer. I've noticed the difference
between versions 2.0 and 2.6, but I don't know when it was introduced
because I don't have the other versions installed.
The code below will create a WMS layer from the UK National Biodiversity
Network (NBN). (The code starting 'NHM...' specifies that this is a UK
species distribution map for the Robin.)
The WMS layer is created with four sub-layers. The code below turns off
visibility for three of the sub-layers, leaving only one visible. (In the
plugin I change the sub-layer visibility depending on the extent of the
map.)
If I run the sample code in QGIS 2.0, I see only the "Grid-2km" sub-layer.
But if I run it in QGIS 2.6, I see all four sub-layers - the
setSublayerVisibility method has no effect.
Can anyone confirm whether or not this is a bug, of if there has been a
change to handling sub-layer visibility that I should be aware of?
url = ("url=https://gis.nbn.org.uk/SingleSpecies/NHMSYS0000530739&"
+
"layers=Grid-100m&layers=Grid-1km&layers=Grid-2km&layers=Grid-10km"
+
"&styles=&styles=&styles=&styles=" +
"&format=image/png&crs=EPSG:27700")
rlayer = QgsRasterLayer(url, 'NBN WMS layer', 'wms')
QgsMapLayerRegistry.instance().addMapLayer(rlayer)
rlayer.setSubLayerVisibility("Grid-10km", False)
rlayer.setSubLayerVisibility("Grid-2km", True)
rlayer.setSubLayerVisibility("Grid-1km", False)
rlayer.setSubLayerVisibility("Grid-100m", False)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141105/12cb7143/attachment-0001.html>
More information about the Qgis-developer
mailing list