6

I have a polygon layer and want to check if there are some polygons overlapping within the same layer. How can I do this?

In ArcGIS, I could run the Intersect tool only by adding the layer I want to check. This doesn't work in QGIS because it requires an overlaying layer.

I tried to add the Topology check "overlap", but this only finds overlapping errors of newly drawn polygons, not existing ones.

I also tried the "Select by Attribute" with overlay_within(@layer) but:

  • It only finds completely overlapping (identical) polygons (I also need to find the polygons that overlap only slightly)
  • It does not create a layer (which would be handy)
7
  • "Check" as in "automatically scan and return the overlapping polygons, or their overlapping parts" or as in "scan visually/manually for overlaps"?
    – Erik
    Sep 12 at 8:54
  • Where can I "check" this?
    – Motti
    Sep 12 at 9:00
  • What is your definition of "check"?
    – Erik
    Sep 12 at 9:24
  • you told me to "check" as in "automatically scan and return the overlapping polygons, or their overlapping parts" or as in "scan visually/manually for overlaps". is this a google research or something I can check in a checkbox in a tool?
    – Motti
    Sep 12 at 9:34
  • "Check" as in "how do you want to do this".
    – Erik
    Sep 12 at 9:44

5 Answers 5

7

You can create a Virtual Layer with DB Manager which joins the table to itself on intersecting polygons, where the id isnt the same.

You need a unique identifier field, mine is named id. My layer is named qwerty. Modify layer name (row 3 and 4) and the id column name (row 6) in the query below and execute:

select  row_number() over() as newid, 
        st_intersection(a.geometry, b.geometry) as geometry
from "qwerty" as a
join "qwerty" as b
on st_intersects(a.geometry, b.geometry)
and a.id<>b.id
where st_area(st_intersection(a.geometry, b.geometry))>0

enter image description here

The same logic using QGIS processing tools:

  1. Field calculate the integer field tempid as @row_number
  2. Intersection (multiple) with Field calculator output as input and overlay layer
  3. Extract by expression "tempid"<"tempid_2"

enter image description here

5
  • I have a lot of touching parcels, which share the same border, but don't overlap. This code finds those and creates a line feature. even tough I have created a overlapping polygon. this overlapping section is not found. I don't have any experience with this type of query. is there a way to modify it the way it only finds polygon-results?
    – Motti
    Sep 12 at 16:29
  • I've added the last line which only select intersections with an area. This should get rid of the lines and any points.
    – BERA
    Sep 12 at 17:27
  • In my case after executing, in the geometry table there is not only "Polygon" but also "GeometryCollection (Line String ...)". After loading the layer, nothing is showed. I can't even change the symbology or zoom to the selected row. but the result in your screenshot is EXACTLY what I'm looking for :-)
    – Motti
    Sep 12 at 18:41
  • You probably need to use CollectionExtract to extract only the polygons. Can you share your data?
    – BERA
    Sep 13 at 5:12
  • 1
    I love how everyone knows a different way to solve this issue, each one as viable as the next.
    – Erik
    Sep 13 at 8:33
4

I suggest you run join attributes by location, with both inputs being your polygon layer, using "overlap" as condition and discard all features which haven't been joined to something. Now you're left with all the overlapping features.

If you really need only the overlapping parts, we need to go down the rabbit hole (at least a bit).

  1. Add the $area to your polygons.
  2. Then run union with your overlapping polygons as both inputs.
  3. Select by expression all polygons in your "unionized" layer with an area = 0 or an area equal to the area added in step 1.
  4. Delete the selected polygons.
  5. Run delete duplicate geometries on the overlaps you got.

This probably is also possible using expressions, overlay_intersects or aggregate and whatsoever, but I prefer a working solution over something I need to fiddle around with two hours.

4

You can use the expression

array_length(overlay_intersects(@layer,$id))>0

Either use it via Select by Expression or run it in Extract by Expression to create a new layer containing the overlapping polygons.

Depending on your exact usecase, you may also want to try one of the other overlay expressions.

1
  • I love how everyone knows a different way to solve this issue, each one as viable as the next.
    – Erik
    Sep 13 at 8:28
4

You can use the Polygon Self-Intersection tool if you have SAGA installed.

enter image description here

  • Polygons: the input polygon layer
  • Identifier: the field name that you want to use to identify the intersected polygons.
  • Intersection: The output intersected polygons.

Then open the attribute table and in the newly added field, look at the attribute values where the pipe character exists |. These are the polygons that have self-intersections.

Example:

Original polygons:

enter image description here

After running the tool:

enter image description here

1
  • 1
    I love how everyone knows a different way to solve this issue, each one as viable as the next.
    – Erik
    Sep 13 at 8:28
2

You can download the LF Tools plugin and run the Overlapping polygons tool.

I made a scratch layer with overlapping polygons (brown polygons) then ran the tool and it made a new layer of the parts that overlapped (maroon polygons) enter image description here

enter image description here

1
  • 2
    I love how everyone knows a different way to solve this issue, each one as viable as the next.
    – Erik
    Sep 13 at 8:28

Your Answer

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

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