[QGIS-Developer] How to load WMS/WFS/WMTS capabilities in PyQGIS ?

Julien Moura julien.moura at isogeo.fr
Fri Jan 19 08:21:33 PST 2018


Hi,

Is there a way to load services capabilities (layers, SRCs, styles...)
using PyQGIS ?

Until now I'm using OWSLib because I knew the lib and it's included in
QGIS, but I'm looking for a proper way and I can't find it. I would expect
a behavior similar to the UI widget:

wms = provider.provider("wms",  "
https://geobretagne.fr/geoserver/lorientagglo/wms?request=GetCapabilities&service=WMS
")
wms.subLayers()
> [layer1, layer2...]
wms_lyr = wms.getLayer("layer1")
lyr = QgsRasterLayer(wms_lyr.uri(), "wms_lyr.title", "wms")
QgsMapLayerRegistry.instance().addMapLayer(lyr)

Regards,
Julien


-- 

Julien Moura
Chef de projets & community manager

*Tél : +33 (0)**6 58 00 30 64*

26 rue du Faubourg Saint-Antoine – 75012 Paris

Métro Bastille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180119/3d3b2be2/attachment.html>


More information about the QGIS-Developer mailing list