Discover the possibilities

Sometimes it can be helpful to apply a filter to our layers, so that only a subset of data is visualized. For example, we would want to focus on cities with more than 1 million inhabitants in a layer with world cities or focus solely on commercial zones in a layer with parcels. In this article, we will specifically look at applying filters to WFS layers. As an example, we take a WFS layer with Flemish municipalities offered by the Flemish Government, where we would like to visualize only the municipality of Ghent in the layer “Gemeente”:

https://geoservices.informatievlaanderen.be/overdrachtdiensten/VRBG/wfs?

We show 3 different methods to apply a filter to a WFS layer in ArcGIS Pro, going from the simplest method to a more advanced one. For the latter, it is useful to be aware of the structure of a WFS. In a link at the end of this article, you can find more information on the structure and communication with WFS layers.

1. Apply definition query WFS after adding layer

The easiest method is not specific for WFS layers, but can also be applied to your own feature layers. It concerns the addition of a definition query. A definition query contains several clauses that are written in the SQL syntax. Multiple definition queries can be created for one layer, but only one can be active at the exact same time.

To add a definition query on a WFS layer in ArcGIS Pro, you must first add the WFS through Connections à New WFS Server. The WFS will then be added to the Servers folder in the Catalog pane. Next, choose one of the layers and add it to your folder in ArcGIS Pro. Once the layer is added, right-click it and select Properties. There you will find the Definition Query tab, where you can add multiple definition queries. To filter on the city of Ghent for the WFS layer of the Flemish Government, you create the following query: «Where NAAM is equal to Gent».

WFS - Definition query

However, this first option has the disadvantage that the filter is only applied after the WFS has been added to ArcGIS Pro. If we are working with large datasets, we obviously want the filter to be applied as soon as the connection with the WFS is set up, in order to avoid having to add layers with large amounts of data. Similar to communicating with the WFS via the URL, we can add specific parameters to visualize solely a subset of our data in the WFS.

2. Add CQL filter at WFS connection

The best specific parameter to add is cql_filter. CQL is the query language specifically created by OGC, and is written in a familiar text-based syntax. When working with the URL of the WFS, this parameter is added at the end of the URL for the WFS, to filter down to the level of parameters in the attribute table. The same can be achieved by adding this parameter to the Custom request parameters when a WFS server connection is established in ArcGIS Pro. For the example of the WFS of the Flemish Government, we add the WFS by selecting Connections à New WFS server. Here, we open the Custom request parameters option and add «cql_filter» as Parameter and «NAAM = Gent» as Value.

WFS - CQL filter

3. Filter on specific Feature ID

The last method is very similar to the previous one. We just add another specific parameter when setting up a WFS connection in ArcGIS Pro. This parameter is FeatureID, the unique ID for each feature in the WFS. For the example of the Flemish Government, we found out the unique ID for the Feature « Gent »  in the WFS layer « Gemeente » : Refgem.203. So we add the WFS again via New WFS server, open the Custom Request Parameters and add «FeatureID» as Parameter and «Refgem.203» as Value.

This method is perfect if we are looking for a unique feature and immediately know the ID for this feature. However, this method is more complicated, as it requires an internal search in the WFS for the FeatureID before it can be used. More information on how to search for the Feature ID can be found in the link at the end about structure & communication with WFS.

3 ways to contact the Esri BeLux Support Team


Email us at the following adress