6

How do I find the differing polygons between two layers in QGIS?

After running the difference operation, however, I get results like this:

diff

I am only interested in the solid (blue) polygons, not the weird lines - which I suspect are the result of rounding error, or previous conversion of the polygon layers from different file types - who knows.

One idea I had was to calculate the area of the polygons and simply select those with non-zero (or above any obvious peak in the distribution) values, but irritatingly the line polygons seem to have substantial areas in many cases.

4
  • 1
    Those 'slivers' could actually be legitimate differenced polygons and not artifacts but hard to say without looking at your original polygon layers. If you only have a handful of the solid blue polygons, you can select them manually and then right-click the layer, go to Save As... and check the Save only selected features option. Then save it as a new shapefile. Alternatively, have you tried the Eliminate sliver polygons tool or the v.clean tool with the rmdangle parameter?
    – Joseph
    Commented Feb 23, 2017 at 12:17
  • Hey, thanks for replying! The slivers are irrelevant for the purpose of the analysis, and there's around 600.000 polygons in each layer all told - the difference operation itself takes around two hours. Fun times. "Eliminate sliver polygons" seems to want to merge neighboring polygons, which is not what I want, and "v.clean" had no effect (out of the parameter settings I've tried - I'll do an exhaustive search just in case). There ought to be some easy check for whether the geometry in question is a "full" polygon or not, and then I could just iterate over the polygons with a python script
    – nkc
    Commented Feb 23, 2017 at 12:34
  • 1
    That sure is a lot of polygons for each layer...have you considered importing them to PostGIS and using the ST_Difference tool? This should reduce the processing time significantly :)
    – Joseph
    Commented Feb 23, 2017 at 12:39
  • Thanks, I'll try it out :) I'm still learning PostGIS to be honest; would the query be something like SELECT ST_Difference(layer1.geom, layer2.geom) FROM layer1 INNER JOIN layer2?
    – nkc
    Commented Feb 23, 2017 at 12:45

1 Answer 1

3

If ST_Difference doesn't get you where you want try a ratio of area and perimeter by making new attribute fields and calculating. You will have to make a judgement call where to set the ratio filter and if the method is suitable enough for the analysis purpose.

1
  • This ended up being the right thing to do. I computed the ratio of area to perimeter and dicked around with a threshold setting for a while. I ended up on the (mostly arbitrary) value of 2, since it seemed to capture the polygons I was interested in.
    – nkc
    Commented Feb 27, 2017 at 8:04

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.