Simplify polygons without creating slithersCode · GIS · rstats geometry · gis · polygons · simplify
When simplifying polygons it’s almost inevitable that you will generate some slither polygons or gaps between the correct polygons. For example, the following image shows two adjoining complex polygons, representing two adjoining administrative areas. Note there are no gaps between the polygons; they are contiguous (the border is between Sheffield and Barnsley LADs, by the way).
Now if we simplify these polygons to reduce their complexity using simplify geometries in QGIS, gaps appear between the original two polygons and they are no longer contiguous.
If you’re just plotting a basic, low resolution thematic map this isn’t necessarily a problem, but it becomes problematic when you try to use these polygons with other data or use the polygons for clipping. There are solutions but correcting them can be a pain, and don’t always work as intended. But why correct them; why not simplify without creating slither polygons in the first place? If you’re an R user the
ms_simplify() function in the
rmapshaper package allows you to do exactly that.
QGIS’s simplify geometries and rmapshaper::ms_simplify() use different arguments for thresholds, so I’ve matched the level of simplification as best I can to ensure a fair test. The QGIS simplified shapefile is 6.6MB, while the rmapshaper simplified shapefile is 5.7MB (so slightly smaller and still without errors introduced).
rmapshaper::ms_simplify() just install and load the library and run it on a
install.packages("rmapshaper") library("rmapshaper") simplified_shape <- ms_simplify(unsimplified_shape)
I’ve created an Rmd notebook you can download and run inside RStudio that takes you through the (very simple) process of simplifying the local authority districts (LADs) in the United Kingdom.