3

I'm having trouble understanding how to find overlapping areas between two polygons (using QGIS, but I'm open to coding if it's any easier), and obtain not only the output polygon, but also which polygons does it come from (I have roughly 50 polygons, some overlap and some doesn´t).

An example with polygons A, B, and C: enter image description here

I want to get the overlap between A-B (without C), A-C (without B), B-C (without A), and A-B-C.

E.g. A-B:

enter image description here

E.g. A-B-C:

enter image description here

I would want an output of :

  • A polygon for each interaction (e.g.: polygon_A_B, polygon_A_C, etc)

  • A dataframe which would tell me which polygons are in which interaction, such as:

    polygon_id      polygon_1    polygon_2   polygon_3
    polygon_A_B     A            B           NA
    polygon_A_C     A            C           NA
    polygon_A_B_C   A            B           C
    
4
  • @BERA No, they are all in different shapefiles...
    – mto23
    Commented May 28 at 13:32
  • Meh... if all where in the same layer, the union tool would do half the work.
    – Erik
    Commented May 28 at 13:33
  • @Erik any way also in QGIS of doing that quickly? i.e. merging all the shapefiles
    – mto23
    Commented May 28 at 13:35
  • You might look at the SAGA polygon self intersection tool in Processing.
    – John
    Commented May 28 at 20:05

1 Answer 1

5
  1. Merge all layers into one
  2. Union the merge output with itself as Input layer, no Overlay layer
  3. Aggregate the output, concatenate the columns, group by $geometry

enter image description here

5
  • 1
    Tried to find this solution using the field calculator, but the tool is way easier. Neat one.
    – Erik
    Commented May 28 at 13:47
  • This works very well, thank you!!
    – mto23
    Commented May 28 at 14:34
  • @BERA I actually just realised that, in the 2nd step (Union), if I don't add anything in the "Overlay layer", I get this error: "Feature could not be written to (...): Could not add feature with geometry type MultiLineString to layer of type MultiPolygon Could not write feature". If I add the "Merged" output as "Overlay layer", it works but I only get the overlaps between two polygons and not three (as you have, and I should have too). I guess it's because of this? Any thoughts are appreciated!
    – mto23
    Commented May 28 at 15:15
  • From what I've understood, this is connected to two polygons being too close to each other and then generating a line. I also saw that the tool "v.clean" can be used to adjust this but still not sure how to use it (not which value to set - I saw somewhere 0.1). But even when using that, the output layer is different and I don't understand how to use aggregate later.
    – mto23
    Commented May 28 at 15:44
  • If you still recieve that error you can try either (or combinations of): Buffer with a very small distance, Snap to Grid and/or Simplify
    – Bera
    Commented May 29 at 4:47

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.