8

I calculated the difference between 2 massive polygon layers with the Difference tool in QGIS. I get the result I wanted...more or less. The problem is that there are a bunch of lines that appear in the middle of the polygons of interest. I tried getting rid of them by calculating their surface and getting rid of those that are really tiny (0.001, 0.01, 0.1ha, etc.), but I still haven't arrived to a satisfying result.

Does anyone have tips to get rid of these skinny line-looking polygons?

2

3 Answers 3

14

You may use the "Roundness" tool that :

Calculates the roundness of each feature and stores it as a new field. The input vector layer must contain polygons.

The roundness of a polygon is defined as 4π × polygon area / perimeter². The roundness value varies between 0 and 1. A perfect circle has a roundness of 1, while a completely flat polygon has a roundness of 0.

Then erase the polygons that fall below a certain roundness (you may need some trial and error to find the exact value that will remove all unwanted polygon without removing "good" polygon)

enter image description here

0
8

In newer versions of QGIS there is a "Grid size" parameter available in the "Geoprocessing Tools" like "Difference" that can avoid the very narrow polygons from appearing altogether.

If you specify a value for this parameter, this will have the following effects:

  • Coordinates will be rounded if the precision grid specified is less precise than the input geometry. Duplicated vertices will be dropped from lines and polygons.
  • Line and polygon geometries will be removed if all vertices are closer together than the grid size or, for polygons, if they become significantly narrower than the grid size.
  • Spikes or sections in Polygons significantly narrower than grid_size after rounding the vertices will be removed.

Based on some tests I did in the past, using a grid size >= 0.00000001 (10e-8) cleaned up all lines in the output of an overlay operation for my data.

As there doesn't seem to be a tool yet in QGIS to apply this on an existing layer, I opened a feature request for it.

enter image description here

2

Another thing you can try: enter image description here

I have two layers: A and B. I want to difference layer A with layer B. enter image description here

  1. Difference with A as input layer, and B as Overlay layer. The output have some narrow slivers: enter image description here

  2. Buffer the Difference output with a small negative buffer distance, to completely erase the slivers but keep the larger polygons: enter image description here

  3. Extract by location, Difference output as "Extract feature from", and Buffer output as "By comparing to the feature from" layer, to only extract the non-slivers from Difference output: enter image description here

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