2

I try to load a WFS including a bbox parameter via PyQGIS. The WFS is loaded without problems, but unfortunately the bbox parameter does not work. If the bbox parameter is added to the query I get all the results, including the results that are outside of the bbox range. When I start the request in the browser or using the QGIS GUI, I get the correctly filtered features. It looks like PyQGIS does not take into account the bbox parameter.

My code looks like this:

vl = QgsVectorLayer("https://wxs.ign.fr/administratif/geoportail/wfs?VERSION=2.0.0&TYPENAMES=ADMINEXPRESS-COG-CARTO.LATEST:arrondissement&COUNT=1000&SRSNAME=EPSG::4326&BBOX=42.374778,-2.109375,47.115000,2.856445", 'water', 'WFS')
QgsMapLayerRegistry.instance().addMapLayer(vl)

Is this a known bug or something missing in my request?

As already said, in the browser or via the QGIS GUI the request works, but not with PyQGIS.

2
  • QGIS Version is 2.18.18
    – eftas
    Commented Apr 30, 2018 at 9:34
  • It's difficult to see how PyQGIS doesn't take BBOX into account, since the request is processed on the server and results returned to you. Looking at the WFS 1.0.0 spec, it appears that SRS is not used on a BBOX, and I have a feeling that only one CRS is supported too, which is why there's no need for CRS/SRS in the BBOX! You say the query works in QGIS so perhaps QGIS is sending a WFS 1.1.0 request?
    – nmtoken
    Commented May 1, 2018 at 8:15

1 Answer 1

0

You must give the bbox srs as well.

vl = QgsVectorLayer("http://geoserver_url/ows?style=&request=GetFeature&service=WFS&version=1.0.0&typeName=dataset:water&bbox=3562017.31020000018179417,5679733.8194363797083497,3563253.31000480009242892,5681088.4972945200279355,EPSG:31467&srsname='EPSG:31467'", 'water', 'WFS')
1
  • Thanks for the tip, unfortunately that does not work either.
    – eftas
    Commented Apr 30, 2018 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.