8

There is a layer in QGIS that contains multiple polygons, and I want to dissolve the polygons which are inside another polygon.

I don't want to dissolve the entire layer of polygons. For example, in the following map, is there a way in the QGIS to make it two polygons only by combining any inner polygon with the bigger one containing it?

I want to select the polygons automatically. It is very hard to select polygons manually since there are more than 1.2K polygons.

enter image description here

2
  • 1
    What have you tried?
    – Taras
    Commented Nov 27, 2021 at 20:25
  • @Taras Run Vector -> Geoprocessing Tools -> Dissolve Commented Nov 28, 2021 at 11:54

3 Answers 3

12

If you want to dissolve in-place:

  1. Start edit mode for the layer.

  2. Select the bounding and interior polygons

  3. Click "Merge selected features" button () in the Advanced digitizing Toolbar.

  4. Repeat 2-3 for all bounding and interior polygons separately.

enter image description here

1
  • Thank you. is there a way to select polygons automatically? Commented Nov 28, 2021 at 11:54
10

To merge all the features of layer 'polygon2' inside the same same polygon from layer 'polygon1' automatically (without manual selection), use Menu Processing / Toolbox / Aggregate (see documentation) with 'polygon2' as input layer and this expression as Group by expression:

array_first(overlay_within('polygon1', $id))

2 purple polygons = layer 'polygon1'; 6 yellow polygons = layer 'polygon2'; aggregated result consists of two features: A) 4 part MultiPolgon with blue outline, B) 2 part MultiPolygon with red outline:

enter image description here

If the polygons are all on the same layer, you can use the following trick:

Buffer the input layer with a (very small) negative buffer of like 0.1 meters. Then set the initial polygon layer as input layer in the Aggregate tool and the buffered layer in the expression:

array_first(overlay_within('buffer', $id))
3
  • Thank you. But unfortunately, all polygons are on the same layer. Commented Nov 28, 2021 at 13:27
  • Then simply replace the layer's name in the expression by your polygon layer's name - in my case: polygon2 instead of polygon1 (or use the variable @layer to get the current layer). Or even easier: dissolve the whole layer and run multipart to single parts.
    – Babel
    Commented Nov 28, 2021 at 13:30
  • Added a solution in case all polygons are on the same layer, see edited answer at the bottom.
    – Babel
    Commented Nov 28, 2021 at 14:09
10

To get as a different layer from the original one, use the following steps.

  1. Select the polygons you want to dissolve

  2. Run "Vector Geometry" -> "Dissolve tool". (Check "Selected features only")

  3. Then run "Vector geometry" -> "Multipart to singleparts" tool for the dissolved layer.

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.