Back in the jungle, it would be a good idea to get an overview!
Especially what the WFS you want to use is able to deliver.
I myself didn't pay much attention to the GetCapabilities-Request in the past.
But the GetCapabilities-document contains really useful information!
So let's explore it.
I'll use the cadastral parcel service of North Rhine-Westphalia subsequently.
It's GetCapabilities-URL is:
Copy https://www.wfs.nrw.de/geobasis/wfs_nw_inspire-flurstuecke_alkis?SERVICE=WFS&REQUEST=GetCapabilities&VERSION=2.0.0
If you don't know the GetCapabilities-URL of the WFS you're using, add a OGC WFS (Web Feature Service) Reader to your FME Workbench.
Then open [Parameters ...] , paste the WFS-URL in [URL] , select a [Feature Type] and set [Max Features] to a small number, e.g. like this:
Next [Run Just This] .
FME sends a request to the service and will get the number of features you specified before.
Now, remember your friend: the Translation Log
Scroll upwards!
You'll see some blue colored URLs. We need the <WFS> Capabilities URL .
Double click or copy & paste it to your browser.
Now we will collect some relevant information.
Copy <ows:Parameter name="AcceptVersions">
<ows:AllowedValues>
<ows:Value>2.0.0</ows:Value>
</ows:AllowedValues>
</ows:Parameter>
AcceptVersions tells you, which WFS versions are supported. Other WFS may support more than one version, e.g.
Copy <ows:Parameter name="AcceptVersions">
<ows:AllowedValues>
<ows:Value>2.0.0</ows:Value>
<ows:Value>1.1.0</ows:Value>
<ows:Value>1.0.0</ows:Value>
</ows:AllowedValues>
</ows:Parameter>
To know the WFS version is important, because you have to use the corresponding filter expression version! We will have a look at it later.
Generally you should use version 2.0.0 if your WFS supports it.
Next, have a look at CountDefault .
Copy <ows:Constraint name="CountDefault">
<ows:NoValues/>
<ows:DefaultValue>100000</ows:DefaultValue>
</ows:Constraint>
The WFS 2.0 specification says about it: "If the server does have a server configured count limit , that limit shall be advertised in the server's capabilities document using the CountDefault constraint. "
In case of our WFS just try it: set Max Feature to nothing and run it.
Result: the WFS returns exactly 100.000 features (approx. 180 MB).
Next scroll down to the section named FeatureTypeList and the FeatureType you want to use, here CadastralParcel :
Copy <wfs:FeatureTypeList>
<wfs:FeatureType xmlns:cp="http://inspire.ec.europa.eu/schemas/cp/4.0">
<wfs:Name>cp:CadastralParcel</wfs:Name>
<wfs:Title>Flurstück</wfs:Title>
<wfs:Abstract>Gebiete, die anhand des Liegenschaftskatasters oder gleichwertiger Verzeichnisse bestimmt werden.</wfs:Abstract>
<ows:Keywords>
<ows:Keyword>Flurstück</ows:Keyword>
<ows:Keyword>Cadastral Parcel</ows:Keyword>
</ows:Keywords>
<wfs:DefaultCRS>urn:ogc:def:crs:EPSG::25832</wfs:DefaultCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/25832</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/25833</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/3034</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/3857</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/4258</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/4326</wfs:OtherCRS>
<wfs:OtherCRS>http://www.opengis.net/def/crs/EPSG/0/900913</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::25833</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::3034</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::3857</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::4258</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::4326</wfs:OtherCRS>
<wfs:OtherCRS>urn:ogc:def:crs:EPSG::900913</wfs:OtherCRS>
Write down the DefaultCRS (Coordinate Reference System)!
It will be relevant when we deal with spatial filters.
Continue scrolling down until you see
There are many intersting things, but we will focus on these three!
Comparison Operators
Comparison Operators are the same as you may know using SQL:
Copy <fes:ComparisonOperators>
<fes:ComparisonOperator name="PropertyIsEqualTo"/>
<fes:ComparisonOperator name="PropertyIsNotEqualTo"/>
<fes:ComparisonOperator name="PropertyIsLessThan"/>
<fes:ComparisonOperator name="PropertyIsGreaterThan"/>
<fes:ComparisonOperator name="PropertyIsLessThanOrEqualTo"/>
<fes:ComparisonOperator name="PropertyIsGreaterThanOrEqualTo"/>
<fes:ComparisonOperator name="PropertyIsLike"/>
<fes:ComparisonOperator name="PropertyIsNull"/>
<fes:ComparisonOperator name="PropertyIsNil"/>
<fes:ComparisonOperator name="PropertyIsBetween"/>
</fes:ComparisonOperators>
PropertyIsEqualTo means "="
PropertyIsNotEqualTo means "!="
PropertyIsLessThan means "<"
You guess it!
Spatial Operators
Spatial Operators may be more interesting:
Copy <fes:SpatialOperators>
<fes:SpatialOperator name="BBOX"/>
<fes:SpatialOperator name="Equals"/>
<fes:SpatialOperator name="Disjoint"/>
<fes:SpatialOperator name="Intersects"/>
<fes:SpatialOperator name="Touches"/>
<fes:SpatialOperator name="Crosses"/>
<fes:SpatialOperator name="Within"/>
<fes:SpatialOperator name="Contains"/>
<fes:SpatialOperator name="Overlaps"/>
<fes:SpatialOperator name="Beyond"/>
<fes:SpatialOperator name="DWithin"/>
</fes:SpatialOperators>
I suggest, that you're familiar with spatial operations!?
We will focus on some of them, especially the Bounding Box (BBOX).
Logical Operators
Using Logical Operators like AND, OR and NOT , you'll be able to combine two or more of the above operators, i.e.
attribute with attribute comparisons
attribute with spatial comparisons
Unfortunately, not all WFS support logical operators. You have to try (and error)!
Wrap it up!
Let's practice ...
Good to know #1
As we're dealing with metadata , would it be interesting for you to know the total number of features in one Feature Type for example CadastralParcels? (Not the total quantity/sum of all features in different Feature Types a WFS holds available).
Yes?
If so, grab the GetFeature URL from the Translation Log (will be explained in detail in The Formula ), delete anything starting with "&NAMESPACES=xmlns... " and replace it by "&resultType=hits " (make sure to keep your Feature Type which is defined in TYPENAMES).
Caution : the keyword resultType is case sensitive !
As a result
Copy https://www.wfs.nrw.de:443/geobasis/wfs_nw_inspire-flurstuecke_alkis?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=cp%3ACadastralParcel&NAMESPACES=xmlns%28cp%2Chttp%3A%2F%2Finspire.ec.europa.eu%2Fschemas%2Fcp%2F4.0%29&OUTPUTFORMAT=application%2Fgml%2Bxml%3B%20version%3D3.2&COUNT=1
becomes to
Copy https://www.wfs.nrw.de:443/geobasis/wfs_nw_inspire-flurstuecke_alkis?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=cp%3ACadastralParcel&resultType=hits
Open this new URL in your favorite browser, safe and open the returned XML document.
Copy <wfs:FeatureCollection
xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.opengis.net/wfs/2.0 http://www.wfs.nrw.de/aaa-suite/schema/ogc/wfs/2.0/wfs.xsd"
timeStamp="2023-09-08T09:29:20.413+02:00"
numberReturned="0"
numberMatched="9359425"
/>
You can see, that on September, ninth, there are 9.359.425 cadastral parcel features.