0

We used to use this WFS-URL in a Python script with a filter on (see below) to filter out features in a certain geographical area, more specifically our town-borders.

https://geoservices.informatievlaanderen.be/overdrachtdiensten/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&PROPERTY_NAME=”VKBO_NISCODE”&CQL_FILTER=VKBO_NISCODE=%2744048%27

We use the attribute 'VKBO_NISCODE' to filter the features. A niscode is a specific town or commune code. Our niscode is number '44048'.

The URL worked perfectly until the government recently changed it.

The new URL is: https://geo.api.vlaanderen.be/VKBO/wfs or https://geo.api.vlaanderen.be/VKBO/wfs?service=WFS&request=GetCapabilities

The above WFS's work, but when I try to place the same filter in the new URL-code (see below), it doesn't load any features.

https://geo.api.vlaanderen.be/VKBO/wfs?service=WFS&request=GetCapabilities&typename=VKBO:Vkbo&PROPERTY_NAME=”VKBO_NISCODE”&CQL_FILTER=VKBO_NISCODE=%2744048%27

The above URL works until 'request', 'service' and 'version'. In other words, de fault must be in the following filter.

Can anybody explain to me how I can make it work?

I'm new to this.

3
  • 1
    GetCapabilities gives capabilities of service, you can't filter it. You need to use GetFeature
    – nmtoken
    Commented Apr 5, 2023 at 9:32
  • 1
    https://geo.api.vlaanderen.be/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&PropertyName=VKBO_NISCODE gives results as expected. If CQL_FILTER used to work but now doesn't it's possible that the old server supported CQL filters and the new server doesn't. CQL filtering may be offered as an extra capability for a WFS, it isn't part of the WFS + Filter Encoding standard.
    – nmtoken
    Commented Apr 5, 2023 at 10:07
  • Hi nmtoken, thanks a lot. That's what I feared (CQL Filter ability of the new server).
    – BramV
    Commented Apr 5, 2023 at 10:28

2 Answers 2

2

The CQL_FILTER parameter is typically used with the GetFeature request and not GetCapabilities request.

So your request should be something like: https://geo.api.vlaanderen.be/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&PROPERTY_NAME=VKBO_NISCODE&CQL_FILTER=VKBO_NISCODE=%2744048%27

5
  • Thanks. I think I already tried that one. Anyway, tried again with your link. The server replied: "Forbidden". So does it mean that this request is getting blocked?
    – BramV
    Commented Apr 5, 2023 at 7:46
  • on my end, the link is working with no issues Commented Apr 5, 2023 at 7:54
  • Hi Mohamed, when I enter the URL in my browser, it works. But when I add it in my Python script, no features appear as output. Script: rootVKBOWFS = 'geo.api.vlaanderen.be/VKBO/…”VKBO_NISCODE”&CQL_FILTER=VKBO_NISCODE=%2744048%27' VKBOWFS = QgsVectorLayer(rootVKBOWFS,'VKBO WFS','wfs') QgsProject.instance().addMapLayer(VKBOWFS)
    – BramV
    Commented Apr 5, 2023 at 8:20
  • could you post the full error message? Commented Apr 5, 2023 at 8:54
  • Downloaden van capabilities mislukt: Error transferring geo.api.vlaanderen.be/VKBO/wfs?PROPERTY_NAME=”VKBO_NISCODE”&CQL_FILTER=VKBO_NISCODE%3D%2744048%27&SERVICE=WFS&REQUEST=GetCapabilities&ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0 - server replied: Forbidden --> First sentence is in Dutch, it means: "Downloading of capabilities failed: error transferring...). This pops up as soon as I enter the URL in WFS/OGC API in QGIS. Can't post a screenshot here, sadly.
    – BramV
    Commented Apr 5, 2023 at 9:11
1

Your https://geo.api.vlaanderen.be/VKBO/wfs?service=WFS&request=GetCapabilities&typename=VKBO:Vkbo&PROPERTY_NAME=”VKBO_NISCODE”&CQL_FILTER=VKBO_NISCODE=%2744048%27 works in giving a GetCapabilities response for the highest version of service supported (2.0.0) because you didn't specify version or acceptversions parameters.

The GetCapabilities request may accept a sections parameter, but is not expecting typename or PROPERTY_NAME or CQL_FILTER and ignores them.

https://geo.api.vlaanderen.be/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&PropertyName=VKBO_NISCODE gives results as expected; all values for just PropertyName VKBO_NISCODE for typename VKBO:Vkbo.

If CQL_FILTER used to work but now doesn't it's possible that the old server supported CQL filters and the new server doesn't. CQL filtering may be offered as an extra capability for a WFS, it isn't part of the WFS + Filter Encoding standard.

A FE filter to get your property value would be:

Filter=<Filter><PropertyIsEqualTo><PropertyName>VKBO_NISCODE</PropertyName><Literal>44048</Literal></PropertyIsEqualTo></Filter>

You need to URL encode that in GetFeature GET request like:

https://geo.api.vlaanderen.be/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&PropertyName=VKBO_NISCODE&Filter=%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3EVKBO_NISCODE%3C%2FPropertyName%3E%3CLiteral%3E44048%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3C%2FFilter%3E

or perhaps you want all values of the typename VKBO:Vkbo when the VKBO_NISCODE PropertyName is 44048 like:

https://geo.api.vlaanderen.be/VKBO/wfs?request=GetFeature&service=WFS&version=1.1.0&typename=VKBO:Vkbo&Filter=%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3EVKBO_NISCODE%3C%2FPropertyName%3E%3CLiteral%3E44048%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3C%2FFilter%3E

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.