Fixing invalid polygon geometries

Invalid geometries can cause a lot of headache: from missing features to odd analysis results.

This post aims to illustrate one of the most common issues and presents an approach that can help with these errors.

The dataset used for this example is the Alaska Shapefile from the QGIS sample data:

This dataset has a couple of issues. One way to find out if a dataset contains errors is the Check Validity tool in the Processing toolbox:

If there are errors, a layer called Error output will be loaded. In our case, there are multiple issues:

If we try to use this dataset for spatial analysis, there will likely be errors. For example, using the Fixed distance buffer tool results in missing features:

Note the errors in the Processing log message panel:

Feature ### has invalid geometry. Skipping ...

So what can we do?

In my experience, GRASS can work wonders for fixing these kind of issues. The idea is to run v.buffer.distance with the distance set to zero:

This will import the dataset into GRASS and run the buffer algorithm without actually growing the polygons. Finally, it should export a fixed version of the geometries:

A quick validity check with the Check validity tool confirms that there are no issues left.


  1. Morten Agerlin said:

    Smart trick – will try that next time I run into the problem.

    It could be worth also mentioning the Grass algorithm v.clean with bpol as selected cleaning tool in processing.

    Typical errors are polygon borders intersecting itself – here I often have had to correct it by manual editing…

    There is also a plugin called “prepair” for Processing to repair “broken” GIS polygons, but I have not had any big success using that.

    • Thanks for sharing!
      GRASS v.clean is very powerful indeed. I’ve used it a couple of times for more involved issues.

  2. Jarosław Sadowski said:

    Anita thanks for sharing this idea!

    I found another interesting one, seems so simple to use as “repair geometry” in ArcMap:

    I wonder did you try it and what do you think about this approach

  3. Kurt said:

    Had bad luck with my trials, in one case it even crashed grass

  4. Hi Anita,

    My name is Anuj Agarwal. I’m Founder of Feedspot.

    I would like to personally congratulate you as your blog Free and Open Source GIS Ramblings has been selected by our panelist as one of the Top 60 GIS Blogs on the web.

    I personally give you a high-five and want to thank you for your contribution to this world. This is the most comprehensive list of Top 60 GIS Blogs on the internet and I’m honored to have you as part of this!

    Also, you have the honor of displaying the badge on your blog.


%d bloggers like this: