QGIS filter maximaal aantal items

Ik heb in QGIS (3.4.14-Madeira, 64bit) een kaartlaag via WFS geopend. Het gaat om de CBS gebiedsindelingen (https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs), laag “cbs_gemeenten_2020_gegeneraliseerd”. Ik wil uit deze laag een reeks gemeenten filteren. Dit doe ik door de kaartlaag na het ophalen te filteren met de query “statnaam IN (‘gemeente a’,‘gemeente b’… ‘gemeente n’)”. Deze manier werkt goed totdat ik 20 gemeentes heb ingevuld. Heb ik hiermee een maximum bereikt dat wordt bepaald door de WFS-service? Of door Qgis? Op welke manier kan ik meer dan 20 specifieke gemeenten filteren?

Hoi Stefan,

Ik heb je probleem kunnen reproduceren in QGIS 3.10.0-A Coruña met het volgende filter op de WFS laag:

statnaam IN ('Appingedam','Delfzijl','Groningen','Loppersum','Almere','Stadskanaal','Veendam','Zeewolde','Achtkarspelen','Ameland','Harlingen','Heerenveen','Leeuwarden','Ooststellingwerf','Opsterland','Schiermonnikoog','Smallingerland','Terschelling','Vlieland','Weststellingwerf','Assen','Coevorden','Emmen','Hoogeveen','Meppel')

Met behulp van de QGIS Network Logger plugin kan je achterhalen hoe het request van QGIS naar de WFS service eruitziet. Schrik niet! De URL is:

https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=cbsgebiedsindelingen:cbs_gemeente_2020_gegeneraliseerd&TYPENAME=cbsgebiedsindelingen:cbs_gemeente_2020_gegeneraliseerd&STARTINDEX=0&COUNT=15000&SRSNAME=urn:ogc:def:crs:EPSG::28992&FILTER=%3Cfes:Filter%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%20xmlns:gml%3D%22http://www.opengis.net/gml/3.2%22%3E%0A%20%3Cfes:And%3E%0A%20%20%3Cfes:BBOX%3E%0A%20%20%20%3Cfes:ValueReference%3Egeom%3C/fes:ValueReference%3E%0A%20%20%20%3Cgml:Envelope%20srsName%3D%22urn:ogc:def:crs:EPSG::28992%22%3E%0A%20%20%20%20%3Cgml:lowerCorner%3E-234218%20348842%3C/gml:lowerCorner%3E%0A%20%20%20%20%3Cgml:upperCorner%3E75926.89999999999417923%20681195%3C/gml:upperCorner%3E%0A%20%20%20%3C/gml:Envelope%3E%0A%20%20%3C/fes:BBOX%3E%0A%20%20%3Cfes:Or%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EAppingedam%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EDelfzijl%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EGroningen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ELoppersum%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EAlmere%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EStadskanaal%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EVeendam%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EZeewolde%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EAchtkarspelen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EAmeland%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EHarlingen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EHeerenveen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ELeeuwarden%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EOoststellingwerf%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EOpsterland%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ESchiermonnikoog%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ESmallingerland%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ETerschelling%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EVlieland%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EWeststellingwerf%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EAssen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3ECoevorden%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EEmmen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EHoogeveen%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%20%3Cfes:PropertyIsEqualTo%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3E%0A%20%20%20%20%3Cfes:ValueReference%3Estatnaam%3C/fes:ValueReference%3E%0A%20%20%20%20%3Cfes:Literal%20xmlns:fes%3D%22http://www.opengis.net/fes/2.0%22%3EMeppel%3C/fes:Literal%3E%0A%20%20%20%3C/fes:PropertyIsEqualTo%3E%0A%20%20%3C/fes:Or%3E%0A%20%3C/fes:And%3E%0A%3C/fes:Filter%3E%0A

Dit gaat ruimschoots over de maximale URL lengte heen van ongeveer 2000 karakters (8781 voor de statistieken). De WFS server antwoord dan ook met:

Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.

Het is ook mogelijk om een WFS request te doen door middel van een HTT POST request. Dan wordt de query meegestuurd in het body van de request. Ik zou eigenlijk verwachten dat QGIS standaard alle WFS requesten met filters dmv een HTTP POST request verstuurd. Ik heb zo snel geen issue hiervoor vinden op de QGIS issue tracker.

Een workaround is om eerst met de ogr2ogr commandline je WFS request te downloaden naar een GeoPackage (of een ander bestandsformaat naar keuze) en deze dan te openen in QGIS:

ogr2ogr -f GPKG cbs_gemeente_2020_gegeneraliseerd.gpkg "WFS:https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?"` -sql "select * from cbs_gemeente_2020_gegeneraliseerd where statnaam IN ('Appingedam','Delfzijl','Groningen','Loppersum','Almere','Stadskanaal','Veendam','Zeewolde','Achtkarspelen','Ameland','Harlingen','Heerenveen','Leeuwarden','Ooststellingwerf','Opsterland','Schiermonnikoog','Smallingerland','Terschelling','Vlieland','Weststellingwerf','Assen','Coevorden','Emmen','Hoogeveen','Meppel')"
2 likes