Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

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).

To use rmapshaper::ms_simplify() just install and load the library and run it on a spatialPolygons* object: