4

How in QGIS do I dissolve/merge polygons taking into account the area of intersection?

For example, if area of intersection less then 15% of polygon area then operation should't apply.

1 Answer 1

6

It may be done using SQL through creating a virtual layer or querying your layer in db manager:

  1. Resave your data into geopackage or spartialite format. We'll need unique id column (in my case it's just "id").
  2. Create a virtual layer based on your layer with the following definition:
/* Intersecting all features with overlapping area > 15% */

    with intersection as (
        select 
            a.id,
            st_union(st_union(a.geometry, b.geometry)) geometry
        from tmp a
        join tmp b
            on a.id < b.id
                and st_intersects(a.geometry, b.geometry)
                and st_area(st_intersection(a.geometry, b.geometry)) >= st_area(a.geometry) * 0.15
                and st_area(st_intersection(a.geometry, b.geometry)) >= st_area(b.geometry) * 0.15
    )

    /* Select all features that were not intersected and join datasets */
    select
        a.id,
        a.geometry
    from tmp a 
    cross join intersection b
    where not st_within(a.geometry, b.geometry)
    union
    select * from intersection

You may also query your layer through dbmanager if it's complicated enough (virtual layers area slow)

enter image description here

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.