by David Crowther
What’s the difference between WMS and WFS and when should I use them?
Using the Open Source Web Map Publishing software – GeoServer – you can publish your vector and raster datasets as either Web Map Services (WMS) or Web Feature Services (WFS).
These services can then be consumed and in the case of WFS data, they can also be edited by a number of client applications, including desktop (QGIS) and many web mapping apps.
For more detailed information on WMS and WFS as Standards – visit the Open Geospatial Consortium’s web pages - https://www.ogc.org/docs/is
In this FAQ we won’t cover these standards in detail, but instead we will discuss when you may wish to use them and how you can configure your GeoServer instance to publish your data in either one or both formats.
WMS – Web Map Services:
WMS feeds for data are now common place. For instance in the UK, agencies such as the Environment Agency use the WMS format to publish many of their spatial flood zone layers. These layers can then easily be consumed within your GIS application and because they are published in Raster format, they are very quick at rendering.
Because WMS layers are raster based and fast rendering, they are perfect layer types to also render within your webGIS applications. For example, below we have Cadline’s webGIS – MapThat – consuming WMS feeds from multiple sources, showing Flood Zones, Conservation Areas, Listed Buildings etc….
If you have your own GeoServer instance, you can harness the power of WMS to publish your own spatial datasets. Publishing spatial data as a WMS feed has a number of advantages including:
Fast rendering for heavy and complex spatial tables:
High Powered styling and labelling options:
WMS is also a great format to publish your Raster Layers, as GeoServer utilises the Image Mosaic Plugin to tile multiple Raster tiles into one simple URL. So, you can easily publish and then consume in your GIS applications, Ordnance Survey Raster tiles and also Historic Mapping tiles to provide basemapping for your users.
WFS – Web Feature Services:
WFS feeds will be based on vector (spatial) datasets and are again a way to publish your source spatial assets as a URL service. This means they can be used to publish data without having to expose complex or sensitive Database Connection parameters.
Desktop GIS applications such as QGIS can then render these WFS feeds as unstyled versions of your data. They have the advantage of allowing end users to view the full Data Table to see all attributes:
And because the end user is accessing the data in vector (spatial) format, they can edit both the attributes….
and also the geometry of the features and save those changes back to the source datasets e.g. a Spatial Database.
.. this means that as soon as the edit is made via the WFS and then saved, your assets in your source Spatial Database are updated and changes are reflected instantly in other mapping apps e.g. your webGIS!
This means the WFS format gives you the benefit of speedy and safe delivery of your data, with the option to allow users to also edit those assets.
However, what if you want to publish a spatial layer as a WMS, but not allow users to access the same data as a WFS – so that you can be assured that no-one can edit your data?
Well,.. there are ways that you can create Users and Roles in your GeoServer instance so that different users have different logins and therefore can only view but not edit layers. Options around Users and Roles are explored in this Cadline blog - https://www.cadlinecommunity.co.uk/hc/en-us/articles/360006525978-GeoServer-User-Security
Or to keep things simple, here is a great tip which allows you to choose which layers are accessibly via WMS or WFS.
By default, all the spatial layers that you create in GeoServer will be accessible from the client application as either WMS or WFS. For example, if I connect to my GeoServer Instance to create a WMS feed – I can see the GM Plots layer….
…. and can then add that to the map.
And thus by default if I connect to the same GeoServer instance as a WFS feed, I can see that same Layer…
and then add that as a WFS feed to the map.
However, in GeoServer (version 2.15.0 and onwards) there is now a PER LAYER setting that allows you to choose whether a Layer is accessible as a WMS, WFS or both.
In GeoServer find your Layer e.g. GM Plots…
and click on it to open its settings. Then in the Publishing Tab, scroll down to the Services Settings section.
Now tick the box to Selectively enable services for the layer, and to only publish this Layer as WMS, move the WFS service across to the Disabled Services pane and then save the layer settings.
The next time that you connect to your GeoServer Instance as a WFS, you will now see that the GM Plots layer is not available to choose from!
So, we can now control which of our layers our end users can access as WMS or WFS.