• Blog posts

    Bio

    by David Crowther

    DC_Geoserver_WMS_1.png

    Question:

    What’s the difference between WMS and WFS and when should I use them?

    Answer:

    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

    DC_Geoserver_WMS_2.jpg

    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.

    DC_Geoserver_WMS_3.jpg

    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….

    DC_Geoserver_WMS_4.jpg

    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:

    DC_Geoserver_WMS_5.jpg

    High Powered styling and labelling options:

    DC_Geoserver_WMS_6.jpg

    DC_Geoserver_WMS_7.jpg

    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.

    DC_Geoserver_WMS_8.jpg

    DC_Geoserver_WMS_9.jpg

    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:

    DC_Geoserver_WMS_10.jpg

    And because the end user is accessing the data in vector (spatial) format, they can edit both the attributes….

    DC_Geoserver_WMS_11.jpg

    and also the geometry of the features and save those changes back to the source datasets e.g. a Spatial Database.

    DC_Geoserver_WMS_12.jpg

    .. 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!

    DC_Geoserver_WMS_13.jpg

    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

    DC_Geoserver_WMS_14.jpg

    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….

    DC_Geoserver_WMS_15.jpg

    …. and can then add that to the map.

    DC_Geoserver_WMS_16.jpg

    And thus by default if I connect to the same GeoServer instance as a WFS feed, I can see that same Layer…

    DC_Geoserver_WMS_17.jpg

    and then add that as a WFS feed to the map.

    DC_Geoserver_WMS_18.jpg

    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…

    DC_Geoserver_WMS_19.jpg

    and click on it to open its settings. Then in the Publishing Tab, scroll down to the Services Settings section.

    DC_Geoserver_WMS_20.jpg

    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.

    DC_Geoserver_WMS_21.jpg

    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!

    DC_Geoserver_WMS_22.jpg

    So, we can now control which of our layers our end users can access as WMS or WFS.