Using QGIS to fix geometry errors

In this brief tutorial we will outline the process of using QGIS to fix geometry errors. Fixing polygon geometry errors in QGIS 2.4 is a relatively simple and straight forward process. The first step is to identify where the errors are using Topology.


Simply put “topology” is the term used to describe how points, lines and polygons relate to each other. In QGIS these relationships can be identified by assigning a set of rules using the “Topology Checker”.

In this example we will identify Polygons that have geometry errors. In QGIS open the “Topology Checker” from the vector menu….vector>topology checker>toplogy checker…

This will open and dock a new “Topology Checker” window in the map view. In the next few steps we will set the rules that will identify the geometry errors for our offending layer.

  • click the “Configure” button
  • select “YOURLAYER” from the drop down menu under “current rules”
  • select “must not have invalid geometies” from the rules list
  • click “Add rule”

  • click “OK”
  • click the “Validate All” button

Polygons with errors are coloured up red. In this example there were only three polygons with geometry errors. By zooming in to these polygons I was able to identify the errors as self intersecting polygons.

These errors occur when a polygon boundaries turns in on itself. This type of error can cause a number of issues including labeling and area query problems. We only have three errors in our example and the obvious solution might be to edit the polygons individually. If, however, there were hundreds of errors this would be a time consuming exercise and may not be a practical approach. In these instances we could import the layer into a GRASS mapset and remove errors by setting appropriate import tolerances.

The GRASS Plugin

GRASS is a plugin that comes embedded with QGIS 2.4. Open the GRASS toolbar by selecting it from the menu….View>Toolbars>GRASS. A new GRASS toolbar will be added to your project.

For us to use the GRASS plugin we will need to create a working environment within GRASS for our project area and then import data into it. To do this we will need to create a GRASS “Location”. Firstly create a new directory in your working folder and name it GRASS. Also make sure that you have set a map view CRS and enabled “on the fly CRS transformations”.

  • click the “New mapset” button
  • select the “GRASS” directory you just created
  • click “Next”
  • enter a “location” name
  • click “Next”
  • select the appropriate CRS
  • click “Next”
  • select “Set current QGIS extent”
  • click “Next”
  • name the new “Mapset”
  • click “Next”
  • click “Finish”


You will notice that the remaining buttons on the GRASS toolbar are no longer “greyed out”.

We now need to import our vector layer into GRASS.

  • click the “Open GRASS tools” button
  • from the “Modules Tree” maximize the “File Management” option
  • > “Import into GRASS”
  • > “Import vector into GRASS”
  • select “ – import loaded vector”

  • select “YOURLAYER” as your “Loaded layer”
  • name the output vector map
  • expand the “Advanced Options”
  • set the “Snapping threshold for boundaries” to “1”
  • set the “Minimum size of area to be imported” to “5” m2


By setting these import tolerances we have eliminated the geometry errors but we should run the “Toplogy checker” again to be sure.

  • select “Topology checker”
  • select “Configure”
  • delete all older rules
  • create the rule using your new “GRASS” layer and “must not have invalid geometries”
  • click “Add Rule”
  • click “Validate All”


The GRASS import tolerances worked well for the layer that I used in this example but may not be suitable for your data. You may need to import your layer a number of times to determine which values work best. The objective being to eliminate as many geometry errors as possible without impacting too heavily on the layer integrity.