2

I look for a solution how I can join several polygons of any arbitrary shape that do not overlap with each other and have no common sides, by creating a new polygon. That is, it should be an output polygon covering the "outer" vertices of several input polygons, but in general repeating their shape (see attached figure, red line) and if possible not covering the total min-max coordinate extent (rectangular) covered by these features. I tried several features in QGIS, in particular Convex Hull and Minimum bounding geometry, but it didn't work out what I needed.

enter image description here

3 Answers 3

1

You could create a multipolygon layer and create your multipolygons from your polygons based on an attribute value, proximity or something else... On these multipolygon features you can then apply the function of your choice: bounding box, oriented bounding box, convex hull and it will "merge like" your original features. Below is an example, the 2 top features are part of the same multipolygon. First picture before and second picture after a convex hull operation. Tested on QGIS.

Before the convex

After the convex hull

0
1

Not a complete solution, but a starting point - maybe someone can further develop the main idea. The basic idea is to connect the centroids of neighboring polygons with a line and than buffer that line. It works if the polygons have an attribute (id in my case) in the order the polygons should be connected. But that is easy to generate.

You can than use the following expression to create a visualization with geometry generator or actual geometries with Menu Processing / Toolbox / Geometry by expression:

buffer (
    collect_geometries (
        array_foreach (
            generate_series (
                1,  
                count( $id)-1
            ),
            make_line ( 
                centroid ( 
                    geometry ( 
                        get_feature_by_id (
                            @layer, 
                            @element
                        )
                    )
                ),
                centroid ( 
                    geometry ( 
                        get_feature_by_id (
                            @layer, 
                            @element+1
                        )
                    )
                )
            )
        )
    ), 0.19
)

Red: original polygons, blue: dynamically created gemoetries using geometry generator with the expression from above: enter image description here

2
  • This buffer approach is really promising! However, in my QGIS, the code only fires for the temporary layer via symbology (after reprojecting to the projected coordinate system). In the toolbox, the code does not work (an expression error is displayed for static shapefile, or eval error "Cannot use aggregate function in this context" for temporary), but it may be a bug. I will have to sort this out... Commented Mar 25, 2021 at 16:57
  • Your question was closed as not enough focused. That's why I edited it, hoping it gets re-opened so that other answers can be added. An even more promising approach seems to connect the vertices of each polygon with the vertices of the next polygon (same order ad the lines in the answer above). In any case an interesting question.
    – Babel
    Commented Mar 25, 2021 at 18:11
1

Finally, I got almost an "ideal" result for my polygons to what I expected - it was the Concave Hull QGIS function, also available in PosGIS and other systems. It worked well for other similar polygons as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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