WFS services are accessed through a URL. For the Stockholm City Traffic Office's Open data, use https://openstreetgs.stockholm.se/geoservice/api//wfs
To access a WFS service more than just the address is needed. If you tried to use the above link, you probably noticed that the result did not make sense even though you used your API key?! The problem is that the service does not know what you are asking for. To let the service know what you want, you will need to use a parameter called request. There are many functions in WFS, but here are some of the most important functions:
GetCapabilities returns an XML document that describes what can and cannot be performed with the specified service. The tag, "OperationsMetadata" lists "Operations" that are available through the service.
GetCapabilities also tells which data that are accessible from the service. The tag "FeatureTypeList" contains a description of what information one can access. The function is requested by using GetCapabilities in the URL parameter "request".
DescribeFeatureType describes how data from the service is defined, i.e. which attributes (value fields) with name and data type an object can have. From the document GetCapabilities we can get the name of a data set by looking for the "name" tag within each "FeatureType".
For example, the link below returns the definition of the object type Bicycle pump.
The function can be requested by including DescribeFeatureType in the URL parameter "request" and then entering the name of a data type in the URL parameter "typeName".
GetFeature is the function that retrieves the actual objects with values from the WFS service.
For example, the following request is sent to retrieve values for all bicycle pumps from the service:
GetFeature supports many more parameters in order to get a refined result. For example, it has support for the parameter "cql_filter" which allows the user to send CQL questions (see Continued Reading) in the request. CQL questions filter objects based on their values. For example, you can search for all bicycle pumps with an address on Bergslagsplan:
Even output format can be changed by the outputFormat parameter. For example, the previous question in JSON format is written as follows:
The function is requested by entering GetFeature in the "request" URL parameter and the name of the data type you want to retrieve in the URL parameter "typeName".
QGIS is a freely available tool for visualization of geodata. Here is a short description of how to use QGIS to easily retrieve data from a WFS service.
More information on how to work with QGIS can be found in the other QGIS guides; Using QGIS to visualize data and
Using QGIS with larger datasets.
To view data from a WFS service in QGIS, start by creating a connection. To do this, select "Add WFS Warehouse ..." in the Layer (“Lager”) menu.
Click New (”Ny”) to create a new connection.
Enter a suitable name for the service and enter the URL of the service. It is advisable to enter 1.1 at "Version" as it is currently the version that works best for QGIS. Choosing Auto will cause version 2.0, which may cause QGIS to be unable to retrieve data. Press OK to create the connection.
Click Connect (“Koppla upp”) to view the datasets available through the service. Select the dataset you want to display and click Add (“Lägg till”).
The data is now displayed in the QGIS map view and is available for further analysis.
Mixed Geometry Types
The Traffic Office's open data publishes certain layers containing mixed geometry types.
QGIS lacks support for using themes (color) for multiple geometry types in the same layer, which means that not all geometries may be visible. These layers end with "_Geom".
To draw all objects, it is recommended to create separate layers for each geometry type.
This can be done by choosing "Create question" ("Skapa fråga") at the bottom of the menu when adding the layer in QGIS.
In the "Filter" field, a filter question can be written, such as "GEOM_TYPE = 'POLYGON'" or "GEOM_TYPE = 'LINE'", to extract a certain geometry type from the data sets that have mixed geometry types. The GEOM_TYPE value is only included in data sets that have mixed geometry types. Press OK followed by Add (“Lägg till”) to add the filtered layer to QGIS.
Repeat for all geometry types if the entire data set is to be displayed.