3

I want to merge adjacent single polygons which are apart from each other.

Important note: I cannot use ArcGIS, I need to do this programatically, in any language (R, Python, Ruby, PostGIS) doesn't really matter which it is, it can be a combination of a scripting or compiled code and/or command line tools.

So far I have tried using Turf.js methods convex (hull) and union. Union doesn't grow/shrink the edges to to complete with the neighbouring polygon, but it rather just creates a a geometry collection of all the polygons processed as a single feature. The convex hull creates a single polygon but ignores the inner points, just the farthest and gives a wrong final shape. I've tried using the Eliminate Sliver Polygons... in the QGIS Vector>Geoprocessing Tools menu but the operation fails with a Python error: **

global name 'QErrorMessage' is not defined Traceback (most recent call last): File "/usr/local/Cellar/qgis-214/2.14.1/QGIS.app/Contents/Resources/python/plugins/fTools/tools/doEliminate.py", line 96, in accept self.eliminate(inLayer, boundary, self.progressBar, outFileName) File "/usr/local/Cellar/qgis-214/2.14.1/QGIS.app/Contents/Resources/python/plugins/fTools/tools/doEliminate.py", line 236, in eliminate QErrorMessage(self).showMessage( NameError: global name 'QErrorMessage' is not defined

3 Adjacent polygons that are suppose to be merged into a single one:

**3 Polygons that are suppose to be merged into a single one**

Desired resulting single polygon shape The expected border is drawn with a red contour.

**Desired resulting single polygon shape**

3

Demo solution with OpenJUMP

Original polygons

enter image description here

Buffer the polygons so much that they overlap and make a union. This can be done as a single operation with OpenJUMP. Flat end cap and mitre join with quite a high limit are good settings.

enter image description here

The gaps between the polygons have disappeared but the union is too large.

enter image description here

Use negative buffer for the union and shrink it. Red outline shows the final result.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.