I'm trying to load a WFS layer in PyQGIS. My WFS uri is for county boundaries here in England. It's open data and pretty light, if you were wanting to recreate the issue.
Here's my code:
uri = 'http://www.geostore.com/OGC/OGCInterface?SERVICE=WFS&UID=UDATAGOV2011&PASSWORD=datagov2011&INTERFACE=ENVIRONMENTWFS&VERSION=2.0.0&LC=0' layer = QgsVectorLayer(uri, "WFS_Layer", "WFS") if not layer.isValid(): print "Layer failed to load!"
Sure enough, the layer is not valid.
I'm following (to the best of my limited ability) the QGIS instructions here: http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/loadlayer.html
I'm losing the thread at this part:
Where in the declaration of
vlayer is the
uri being passed in? I feel I'm missing something fundamental.
Can anyone post working code? It'd be awesome to be able to get PyQGIS and WFS working nicely!