The Topology Checker plugin
Topology is a set of rules that defines the spatial relationship between adjacent features, and it also defines and enforces data integrity and validity.
This recipe shows you how to use the built-in Topology Checker plugin to find topology errors in vector layers.
To follow this recipe, load the census_wake2000_topology.shp and roadsmajor.shp layers from the sample data. Additionally, make sure that the Topology Checker plugin is enabled in Plugin Manager.
The Topology Checker plugin allows us to test a vector layer or its part for different topology errors. Before we can use this, we should load all the layers that we want to test in QGIS and then configure topology rules:
- Enable the Topology Checker panel in the View | Panels menu. This should add the plugin panel to the user interface, as shown in the following screenshot:
- Click on the Configure button at the bottom of the plugin panel to open the Topology Rule Settings dialog:
- To set a rule, choose a layer that you want to check in the first combobox. Select the
roadsmajor layer. - Then, select the rule from the second combobox, for example, must not have dangles. As this rule needs only one layer, the third combobox disappears.
- Note that the list of available rules depends on the geometry type of the target layer; also, some rules allow the testing of the spatial relationship between two layers.
- Click on the Add Rule button to add rule to the list of current rules:
- Let's add another rule, this time to check the polygonal layer. Select
census_wake2000_topology as the target layer. - Select must not overlap as the rule and click on the Add Rule button to create a new rule.
- Using the same approach, add another two rules to check this layer: must not have gaps and must not have duplicates:
- Click on the OK button to save your settings and close the dialog.
- Now, when we have defined the rules, we can check topology of the whole layers by clicking on the Validate All button or only features within visible area by clicking on the Validate Extent button. For this recipe, we will validate all layers, so click on the Validate All button.
- After some time (this depends on the number of the features in the layer and computer speed), all detected topology errors will be displayed in the plugin panel, as shown in the following screenshot:
- If the Show errors checkbox is activated (this is the default setting), topology errors that can be visualized will also be highlighted in red on the map:
- Selecting the error in the plugin panel will center the QGIS map canvas on the problematic feature and highlight it in green if possible.
The Topology Checker plugin uses the GEOS library as well as its own algorithms to check spatial relationships between features in the vector layer.