Topology rules define the permissible relationships of features within a given GIS layer or between features in two different GIS layers. An example is that features in a road dataset must be connected to other roads at both ends, unless the road is specified as a dead end street.
Advantage of topology over queries
A lot of the checks that topology rules carry out could be achieved using spatial queries. You may have to use queries if the GIS software you’re using doesn’t have a topology feature.
Topology rules have the advantage that they only need be created once and then they can check your work as you go.
Queries would need to be re-created each time they are run. They can be saved, depending on the GIS being used, but this is still more time consuming and it is a task that must be carried out separately at the end of a work session.
QGIS 2.2 topology tool has the following rules pre-defined:-
- End points must be covered by (e.g. a railway line usually begins and ends at a station)
- Must contain (e.g. a building polygon must contain at least one address point seed)
- Must not have dangles (a line must begin and end at another line)
- Must not have duplicates (each feature should be unique, e.g. postcode areas)
- Must not have gaps (e.g. administrative area polygons cannot have gaps)
- Must not have invalid geometries
- Must not have multi-part geometries (each feature should be a separate entry)
- Must not overlap (e.g. administrative area polygons cannot overlap each other)
- Must not overlap with (a feature from layer must not overlap with another layer)
Example 1 – Roads must not have dangles
The following example uses the “Must not have dangles” rule to identify polylines from a roads dataset that are not snapped to other lines. Roads usually begin and end at a junction with another road, so this is a useful rule to identify where lines were not correctly snapped together.
To create and validate a Topology Rule
- Open the Topology Panel, by selecting Vector menu, Topology Checker, Topology Checker
- The Topology Panel appears in the lower right corner of the QGIS desktop window
- Press the Configure button to open the Topology Rule Settings dialog
- The top of the box will have 2 or 3 pull down boxes depending on the layer and rule that is chosen. Use these to build the rule and then press the Add Rule button.
- Press OK when done, the dialog box closes and the window returns to the QGIS Desktop.
- Press either the Validate All or Validate extent, depending on whether you wish to validate the entire dataset or just the current view extent.
- The errors will be listed. Double click on a row will make the map window zoom and pan to the error.