Web Feature Service
The OpenGISĀ® Web Feature Service (WFS) Interface Standard defines a set of interfaces for accessing geographic information at the feature and feature property level over the Internet. A feature is an abstraction of real world phenomena, that is it is a representation of anything that can be found in the world. The attributes or characteristics of a geographic feature are referred to as feature properties. WFS offer the means to retrieve or query geographic features in a manner independent of the underlying data stores they publish. Where a WFS is authorized to do so, the service can also update or delete geographic features. An instance of a WFS is also able to store queries in order to enable client applications to retrieve or execute the queries at a later point in time (OGC, 2014). The OGC WFS 2.0.0 forms the basis of the ISO 19142 standard.
WFS provides a standard interface for requesting vector geospatial data consisting of geographic features and their properties. The benefit of this is that WFS clients can request source data from multiple WFS servers, and then render the data for display on the client or process the data further as part of a workflow. The standard guarantees that the data can be accessed consistently with other data. Feature properties encoded using common data types such as text strings, date and time can also be accessed consistently.
GetCapabilities Request
Returns metadata about the service, in machine-readable (and human-readable) format. including supported operations and parameters, and a list of the available feature types. 1 shows the parameters of this operation.
Parameters of the WFS GetCapabilities request
Parameter | Value Description |
---|---|
SERVICE | In this case the value is WFS telling the server which service request is coming. |
VERSION | Specifies what version of the WFS service specification is being requested, 1.0.0 1.1.0 2.0.0 2.0.2. |
REQUEST | Tells the WFS server which operation is being requested. In this case, GetCapabilities. |
The example below shows how a WFS GetCapabilities request looks like:
https://gip.itc.utwente.nl/services/world_admin
?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities
Check the response document to see how it describes what the service can do. Besides available data and coordinate systems it also shows which spatial operators are available.
DescribeFeatureType Request
The DescribeFeatureType operation returns a schema description of feature types offered by a WFS instance. The schema descriptions define how a WFS expects feature instances to be encoded on input and how feature instances shall be encoded on output. 1 shows the parameters of this operation.
Parameters of the WFS DescribeFeatureType request
Parameter | Value Description |
---|---|
SERVICE | In this case the value is WFS telling the server which service request is coming. |
VERSION | Specifies what version of the WFS service specification is being requested, 1.0.0 1.1.0 2.0.0 2.0.2. |
REQUEST | Tells the WFS server which operation is being requested. In this case, DescribeFeatureType. |
TYPENAMES | The name of the feature layer for which a description is requested. |
This is an example of a DescribeFeatureType request:
https://gip.itc.utwente.nl/services/world_admin
?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=country_borders
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?xml version='1.0' encoding="UTF-8" ?> <schema targetNamespace="http://mapserver.gis.umn.edu/mapserver" xmlns:wld="http://mapserver.gis.umn.edu/mapserver" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="0.1" > <import namespace="http://www.opengis.net/gml" schemaLocation="https://schemas.opengeospatial.net/gml/3.1.1/base/gml.xsd" /> <element name="country_borders" type="wld:country_bordersType" substitutionGroup="gml:_Feature" /> <complexType name="country_bordersType"> <complexContent> <extension base="gml:AbstractFeatureType"> <sequence> <element name="msGeometry" type="gml:GeometryPropertyType" minOccurs="0" maxOccurs="1"/> <element name="ogc_id" minOccurs="0" type="string"/> <element name="cntry_name" minOccurs="0" type="string"/> <element name="cntry_long_name" minOccurs="0" type="string"/> <element name="cntry_type" minOccurs="0" type="string"/> <element name="pop_est" minOccurs="0" type="string"/> <element name="economy" minOccurs="0" type="string"/> <element name="iso_code" minOccurs="0" type="string"/> <element name="continent" minOccurs="0" type="string"/> <element name="subregion" minOccurs="0" type="string"/> </sequence> </extension> </complexContent> </complexType> </schema> |
GetFeature Request
A WFS server responding to a GetFeature request returns a collection of geographic feature instances filtered according to criteria set by the requesting client. The GetFeature request queries the server with a set of parameters describing the geographic features to return.3 shows the parameters available for this operation.
Parameters of the WFS GetFeature request
Parameter | Value Description |
---|---|
SERVICE | In this case the value is WFS telling the server which service request is coming. |
VERSION | Specifies what version of the WFS service specification is being requested, 1.0.0 1.1.0 2.0.0 2.0.2. |
REQUEST | Tells the WFS server which operation is being requested. In this case, GetFeature. |
TYPENAMES | Determines the collection of feature instances to return. |
BBOX | This parameter is a comma-separated list of four numbers that indicate the minimum and maximum bounding coordinates of the feature instances that should be returned. |
COUNT | Value to limit the number of features in the response. |
MAXFATURES | Value to limit the response by. Same as COUNT. |
FEATUREID | Only retrieve the feature with the specified identifier. |
FILTER | A filter expression based on the OGC Filter Encoding standard, which provides and XML based KVP encoding. |
The simplest GetFeature request is one that downloads the feature collection without any constraints to filter the content by. But, since we are dealing with a very large dataset, we will include a filter using the MAXFEATURES parameter. An example of such a request is shown below.
https://gip.itc.utwente.nl/services/world_admin
?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=country_borders&MAXFEATURES=1
An extract of the response resulting from the above request is shown in 2. The output formta in this case is the XML, which is the default according to the standard. Notice that the response contains a multipolygon representation and corresponding properties of a country, which name is 'Azerbaijan'. Check how every individual member of the multipolygon has a unique identifier. Try the request in a browser tab and explore the response content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
<?xml version='1.0' encoding="UTF-8" ?> <wfs:FeatureCollection xmlns:wld="http://mapserver.gis.umn.edu/mapserver" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver https://gip.itc.utwente.nl/services..."> <wfs:boundedBy> <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326"> <gml:lowerCorner>38.392645 44.774559</gml:lowerCorner> <gml:upperCorner>41.890442 50.625743</gml:upperCorner> </gml:Envelope> </wfs:boundedBy> <wfs:member> <wld:country_borders gml:id="country_borders.18"> <gml:boundedBy> <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326"> <gml:lowerCorner>38.392645 44.774559</gml:lowerCorner> <gml:upperCorner>41.890442 50.625743</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <wld:msGeometry> <gml:MultiSurface gml:id="country_borders.18.1" srsName="urn:ogc:def:crs:EPSG::4326"> <gml:surfaceMember> <gml:Polygon gml:id="country_borders.18.2"> <gml:exterior> <gml:LinearRing> <gml:posList srsDimension="2">39.749820 45.074999 39.684401 45.141255 39.667709 45.151538 39.649209 45.155879 39.625851 45.154225 39.589833 45.144407 39.575260 45.148334 39.565545 45.167920 39.572314 45.204765 39.592727 45.233187 39.599703 45.259955 39.592918 45.266191 39.565855 45.291064 39.545081 45.302898 39.533815 45.312975 39.529268 45.327548 39.525857 45.374884 39.518778 45.392350 39.493827 45.423937 39.493714 45.424080 39.488857 45.434828 39.487513 45.446094 39.489270 45.457463 39.493663 45.468625 39.497177 45.479270 39.536813 45.559679 39.545391 dotdotdot 44.928399 39.584355 44.898427 39.605956 44.886438 39.617583 44.865354 39.620528 44.869281 39.625076 44.872279 39.625593 44.849231 39.628797 44.827837 39.630540 44.823953 39.636962 44.809647 39.639902 44.806993 39.652361 44.795746 39.690240 44.784325 39.702797 44.774559 39.712409 44.802929 39.718920 44.849334 39.718404 44.893053 39.724708 44.927159 39.735965 44.953215 39.738506 44.959095 39.760468 44.995992 39.770390 45.033509 39.757213 45.067512 39.749820 45.074999 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> <gml:surfaceMember> <gml:Polygon gml:id="country_borders.18.3"> <gml:exterior> <gml:LinearRing> <gml:posList srsDimension="2">40.337836 50.606944 40.326077 50.621267 40.310370 50.625743 40.299994 50.618907 40.303697 50.600108 40.300605 50.587576 40.310045 50.572765 40.324856 50.562999 40.337836 50.565278 40.330024 50.578298 40.332343 50.587901 40.337470 50.596690 40.337836 50.606944 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> <gml:surfaceMember> <gml:Polygon gml:id="country_borders.18.4"> <gml:exterior> <gml:LinearRing> <gml:posList srsDimension="2">40.481879 50.326427 40.476874 50.338634 40.480658 50.353689 40.474433 50.360525 40.453559 50.362804 40.442572 50.372569 40.433987 50.385020 40.420396 50.395274 40.408515 50.396251 40.401679 50.388438 40.399075 50.373546 40.399888 50.353689 40.424221 50.358653 40.458075 50.326020 40.481879 50.326427 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> <gml:surfaceMember> <gml:Polygon gml:id="country_borders.18.5"> <gml:exterior> <gml:LinearRing> <gml:posList srsDimension="2">40.979050 45.220474 40.967991 45.209932 40.970834 45.186781 40.993830 45.177170 40.996413 45.180270 40.997912 45.183784 40.998377 45.187712 40.997809 45.191846 40.979050 45.220474 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> <gml:surfaceMember> <gml:Polygon gml:id="country_borders.18.6"> <gml:exterior> <gml:LinearRing> <gml:posList srsDimension="2">41.046281 45.029995 41.023234 45.015732 41.032639 44.979456 41.044834 44.966950 41.059924 44.960697 41.073773 44.963953 41.082041 44.979456 41.074910 45.018885 41.046281 45.029995 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> dotdotdot </gml:MultiSurface> </wld:msGeometry> <wld:ogc_id>18</wld:ogc_id> <wld:cntry_name>Azerbaijan</wld:cntry_name> <wld:cntry_long_name>Azerbaijan</wld:cntry_long_name> <wld:cntry_type>Sovereign country</wld:cntry_type> <wld:pop_est>8238672</wld:pop_est> <wld:economy>6. Developing region</wld:economy> <wld:iso_code>AZ</wld:iso_code> <wld:continent>Asia</wld:continent> <wld:subregion>Western Asia</wld:subregion> </wld:country_borders> </wfs:member> </wfs:FeatureCollection> |
There is an additional service available for this exercise. Use a GetCapabilities request to determine what data is available via this service. The base URL of the world_features
service is:
https://gip.itc.utwente.nl/services/world_features?
Create a GetFeature request to retrieve some of the features of the world_features
service.
Additional paraemeters can be added to a GetFeature request to alter the content of the response. The example below uses a bounding box to filter out features and it also specifies a different output format.
https://gip.itc.utwente.nl/services/world_admin
?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=country_borders&OUTPUTFORMAT=geojson&BBOX=-25.7,62.7,-12.2,66.9
An excerpt of the response to this request is shown in 3. In this case the format of the response is GeoJSON.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{ "type": "FeatureCollection", "features": [{ "type": "Feature", "id": "159", "geometry": { "type": "Polygon", "coordinates": [[[57.7138778,-20.0961240],[57.7179468,-20.0969378],[57.7297469,-20.0951474], [57.7336532,-20.0961240],[57.7448023,-20.1050758],[57.7477320,-20.1115048],[57.7444768, -20.1438128],[57.7522079,-20.1542294],[57.7625432,-20.1620419],[57.7721460,-20.1905250], [57.7913518,-20.2121721],[57.7957463,-20.2227516],[57.7939559,-20.2467587],[57.7889104, -20.2741839],[57.7781682,-20.3047828],[57.7758895,-20.3204078],[57.7815048,-20.3357073], dotdotdot -19.7330055],[63.4165145,-19.7364234],[63.4006454,-19.7448870],[63.3855900,-19.7560361]], [[56.5686141,-10.3864072],[56.5693466,-10.4065081],[56.5485132,-10.3820126],[56.5297958, -10.3529599],[56.5245874,-10.3400204],[56.5241805,-10.3300107],[56.5255640,-10.3273251], [56.5276799,-10.3253720],[56.5310165,-10.3241513],[56.5356551,-10.3239072],[56.5428166, -10.3464495],[56.5686141,-10.3864072]]] }, "properties": { "country_name": "Mauritius", "cntry_long_name": "Mauritius", "cntry_type": "Sovereign country", "continent": "Seven seas (open ocean)", "subregion": "Eastern Africa", "population": "1284264", "economy": "6. Developing region", "iso_code": "MU" } }] } |
It is also possible to include a query expression in the request via the FILTER parameter. This filter expression is similar to the 'Where' clause in SQL. The filter is specified using a single predicate element, or by combining various predicates using logical operators. Either comparison or spatial operators can be used. The example below shows how the PropertyIsEqualTo operator is used to match a property value against a given literal. Filter encoding falls outside the scope of this exercise. More information can be found through the OGC Standards page. Test this request to see the results.
https://gip.itc.utwente.nl/services/world_admin
?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=country_borders&MAXFEATURES=1&OUTPUTFORMAT=geojson&FILTER=<Filter><PropertyIsEqualTo><PropertyName>cntry_name</PropertyName><Literal>Aruba</Literal></PropertyIsEqualTo></Filter>
Construct two separate GetFeature request to retrieve the data of two countries, one in Europe and another one in Africa. Use different filter options for each request.