1

I have a shapefile with lots of overlapping polygons made out of buffering street lines. I need to clip them so that the overlapping part goes to only one feature and gets excluded from the other, which I found I can accomplish with the Clipper plugin, as the image shows: enter image description here

However, with that extension I would have to select one feature at a time and click on the 'Clipper' plugin button. Is there any way I can create a script or some sort of action so that QGIS runs this automatically (select one feature, 'clip', select next feature, 'clip' and so on)? If so, could it select the features in a specified order, such as, according to the values in my 'length' column (from highest to lowest)?

If there's no way to do it, any ideas on how to accomplish clipping all these overlaps (thousands of polygons)?

  • 1
    You can write pyQGIS script to loop through your layers by length as you mentioned and use the clipper python library github.com/demarcog/Clipper/blob/master3/clipper.py – Shiko Sep 12 '18 at 21:35
  • Nice, I think that would solve it. But.... I'm really new to python, so I'm struggling a lot with this. I found some info about looping through the features, but not sure how to make the loop in my wanted sequence. Any tips on how to do it, or somewhere I could learn? – nessime Sep 13 '18 at 12:06
  • If you are using QGIS heavily and if you do automation from time to time, then it is very beneficial to use & learn python and it shouldn't be a big deal if you did programming before. Regarding your question about ordering in feature, I can see that it is possible, check below link: gis.stackexchange.com/questions/284837/… and for pythons with QGIS, below link is the best resource docs.qgis.org/2.18/en/docs/pyqgis_developer_cookbook – Shiko Sep 13 '18 at 21:05
1

I don't think there's a need to script this process. You can try the following:

  1. Split your buffers into 2 layers - Level 1 and Level 2. Level 1 should be the polygons you want to keep when you get an overlap and level 2 should be the ones you want to remove.

  2. Use the difference tool to get the areas in level 2 that don't overlap level 1.

  3. Union the result of the difference tool with level 1

  • Thanks for the answer. The problem is I have a network of streets and they are not all orthogonal, so I would have intersections inside Level 1 that would need to be solved too somehow. – nessime Sep 13 '18 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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