5

I'm trying to 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.

Any ideas?

  • 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 Feb 23 '17 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 Feb 23 '17 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 Feb 23 '17 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 Feb 23 '17 at 12:45
2

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.

^ I'd rather this be a comment over an answer but my user is too new to comment.

  • 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 Feb 27 '17 at 8:04

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.