3

I have a large vector shapefile dataset containing polygons, many of which overlap.

I want to assign each overlapping section to one of the original overlapping polygons. E.g. if polygon A overlaps polygon B, create a polygon C consisting of only the overlapping section of A and B and assign C to either A or B. The polygons are not continuous. Some non-overlapping polygons share boundaries and some are separated and they need to stay this way.

Is there a straightforward way of doing this in QGIS?

The data originally contained lots of invalid polygons so I started by cleaning it using 'LWGEOM Make Valid' plugin, then used the 'Saga Self-intersect' tool to create the 'C' polygons, The 'C' polygons have no attributes.

I exported the 'C' polygons into their own shapefile. I exported the 'AB' polygons into their own shapefile.

How to merge the 'C's' into the 'AB's'?

I thought a nearest neighbour solution would work, merging or dissolving the 'C' polygons with their nearest 'AB' polygon.

I'm in the process of running the 'QGIS NN Join plugin' using 'AB' as input layer and 'C' as join layer. So far this has been running for 2 hours and has hit 2% which would consume a lot of time for 11 datasets.

I would prefer a solution in QGIS but could also access ArcGIS or try in R if necessary.

3
  • The nnjoin plugin only joins the attributes, but won't merge the geometries. You'll need to dissolve by attributes next.
    – csk
    Mar 28, 2018 at 17:14
  • A couple of suggestions: save a small subset of your data to test the processing steps on. This will save a lot of time in finding the right workflow. Once you find the right workflow, use the graphical modeler to automate the process.
    – csk
    Mar 28, 2018 at 17:16
  • NNJoin joins the attributes of nearest neighbors. Each A and B polygon are equally near to each C polygon. Maybe that's confusing nnjoin, and slowing it down. Could you split the A and B polygons into separate layers? Then run nnjoin on layer A and layer C, so there's only one nearest neighbor for each C polygon.
    – csk
    Mar 28, 2018 at 17:19

1 Answer 1

1

The SAGA Polygon self-intersection would have created new ID field to store the combination of overlapped polygons. Please keep it when you export it as Polygon C.

enter image description here Example output of Polygon self-intersection

With a bit of editing, this can be used as id field to put together with Polygon A (or Polygon B).

For instance, if we want to use second number from ID, expression like:

substr( "ID", strpos("ID", '|')+1, 1)  

will return below.

enter image description here

(Please modify it to fit with your data. If you want to use the first one, it will be substr( "ID", strpos("ID", '|')-1, 1). )

After merging them, Collect geometries (QGIS 3.0) or Singleparts to multipart using this field (overlap in the above example) as Unique ID will do the job.

1
  • 1
    Thanks for the responses. I've solved it using a sample of the data as suggested by csk. The answer from Kazuhito didn't quite do the trick but set me on the right track. The expression didn't work, I think due to the vertical bar which is recognised as having a different function. I therefore replaced all the '|' with '-' and used left( "ID, strpos( "ID", '-')-1) to split the ID string. I then merged the 'AB' and 'C' vector layers and used 'Dissolve' to dissolve polygons with the same ID. Thanks again for the replies. Now to try it on the full datasets!
    – Adam G
    Apr 3, 2018 at 9:44

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.