I am using QGIS version 3.10. I have a farm boundaries layer (https://drive.google.com/drive/folders/1xYZmSboM75GACCWQyx-06wZ3EdHBcMrM?usp=sharing), and want to merge certain adjacent polygons into one fenceless area (the resultant merged area will be a nature reserve in which the fences between farms have been removed).

Farm boundaries layer (purple) with selected farms which I would like to merge into one fenceless area

I tried to use the following method to achieve this: toggle editing -> clicked on polygons I want to merge -> merge selected features. A table "Merge Feature Attributes" pops up and from here I am not sure what to do, because, whichever option in the merge features table I select, the result is not what I want. For example, if I say skip all fields the result is that only some line segments have been removed:

Result after I merge the features

The ultimate aim is to have the farm boundaries layer with the line segments between the selected polygons removed. I am analysing the movement of wildlife (which in the nature reserve is unobstructed by fences).

Additionally, as a second question, I would like to find out how to use a different method to achieve the same goal: I have the same farm boundaries layer (green) and a national park layer (pink). I deleted the farms that belong to the nature reserve (white area):

Second method: Saving the space between two layers as a new layer

Is it possible to save out the white area as a new polygon (without having to use digitising tools) and then merge it with the farm boundaries layer?

  • 1
    Merge is a sensible method but if your farm boundaries polygons have geometry or topology errors, you can get messy results. You might run a check validity to see if you have geometry errors and if so maybe Fix Geometries will help. I'd run a GRASS clean for the topology but that might be more learning than you want to do. You could try the Snap geometries to layer tool with your farm polys as input and reference which is easier to learn. Then you could try to select the farms you want and then merge the polygons again.
    – John
    Feb 4, 2021 at 21:00
  • Hi johns, thank you. I will have a look if I can do as you said and report back.
    – Stef
    Feb 4, 2021 at 21:30
  • I decided to clean the topology, as there are over 2000 topology errors (overlaps and gaps) in my farm layer. I want to use break, rmdupl and rmarea for cleaning. I read somewhere that it is best to check the area sizes of the polygons in order to find a suitable tolerance level to use for rmarea. I have around 1000 farm polygons, so I do not see this as a way for me. Is there another way of determining the tolerance level?
    – Stef
    Feb 5, 2021 at 20:39
  • I would also use the snap and bpol tools. If you have a layer with a known tolerance then I'd start with that and check my results both as to the numbers of polygons and how they look up close. You can check any new or sliver polygons to see what happened. If you have no initial layer tolerance you might check some of the topology errors to see how much of a change is needed to get rid of gaps or overlaps by moving vertices and then try that. After running a clean if there are still many errors increase the tolerance and see how that looks.
    – John
    Feb 8, 2021 at 14:25

5 Answers 5


Here the updated answer/solution to my question (in detail):

Merging the polygons was not working because of topology errors in my shapefile (in my case these errors were due to slivers/gaps between polygons). There seem to be several methods in QGIS (and GRASS) one can use to tackle topology errors, but the following worked best for me:

  1. I removed those rows in the attribute table where my polygon area was zero: Open up Attribute Table > sort the Area column so that the zero values are at the top > select Toggle editing mode > Select the rows you want to delete > Select Remove selected feature > Deselect Toggle editing mode and save the changes
  2. Go to the Processing Toolbox in QGIS > type in Snap geometries to layer in search (this can be found under Vector geometry) and open > In my case the Input and reference layer were the same (my farm shapefile) > Tolerance was put to 15 m as this was the gap width of most of the slivers between polygons > Behaviour was put to *snap to anchor mode (single layer only) > select if and where you want to save the layer > Run. The output will be a new layer in which all the slivers should have been removed.
  3. To check if all topology errors have been removed, go to Vector > Check Geometries > Select the layer you want to clean (must be the layer produced in Step 2 above) as Input vector layer. Here there are many options you can select to make sure all topology errors are cleaned. For my case, I checked Check for overlaps smaller than and *Check for gaps smaller than * under Topology checks and put in a value of 30 (note the unit is map units squared) for both, as this made sense for my data > save output and Run. Hint: I found the information from this webpage very useful: Geodose webpage (scroll to bottom where it says Clean Topology Error with Geometry Checker Plugin)
  4. Clean the topology errors (see webpage above)

The result was a clean layer. In order to merge my farm polygons, I used the Aggregate tool in the Processing toolbox (here you can make selections on what you want to do - for me it was important that the area of the merged polygon was a sum of all areas of the input polygons). The output was the merged polygon, which I had to then combine with my original farm layer.

I don't know if I took the best route in combining both layers (there must be an easier way), but this is how I did it: I selected all the features on the original farm layer that I wanted to merge > Toggle editing > Delete selected. Then all I had to do was go to Vector > Data Management Tools > Merge Vector layers > Select both layers as input (original farm layer and merged farms layer) & make sure your CRS is correct. And done.

Another way is the following, but it was less useful as it only cleaned the topology errors of my merged farm polygons (I think):

  1. Use "Select Features by Area" button -> select the polygons to be merged
  2. Select "Toggle Editing" mode -> then "Merge selected features"
  3. Go to "Vector" -> "Geoprocessing Tools" -> "Buffer"
  4. Apply a buffer of 0.005 m to the merged features layer (this may vary from case to case, best way is to measure gap widths and use a buffer greater than the largest gap width you have measured).
  5. Apply a negative buffer of the same width (in my case, - 0.005 m) to restore the outer boundaries.

I suggest trying "Dissolve" first. Select those adjoining areas then go to 'Vector'-> 'Geoprocessing Tools' -> 'Dissolve'. Choose your farm boundaries feature, check 'Selected features only', run it. You can then run 'Merge' as you mentioned in your original question.

enter image description here

  • cm1, thank you! Unfortunately it gave me the same result as the "Merge Features" method - broken, but not dissolved, lines. Do you perhaps know why this is the case?
    – Stef
    Feb 4, 2021 at 21:22
  • You might try using 'Fill holes' from the Processing toolbox after the 'Dissolve' (and applied to the new dissolved feature). I would think there must be some topology errors between the polygons resulting in those artifacts after the Dissolve.
    – cm1
    Feb 4, 2021 at 21:42
  • 2
    To get an actual answer that adresses your problem, it would be helpful if you provided the data you use. Otherwise, it's just guesswork and speculation about possible reasons.
    – Babel
    Feb 5, 2021 at 7:04
  • I provided the farm shapefile via Google Drive link in my original question - I hope this is suitable? I need to clean the topology of the entire layer in order to analyse animal movements (and to merge certain farm polygons, which I am unable to do otherwise).
    – Stef
    Feb 5, 2021 at 21:12
  • 1
    see gis.stackexchange.com/questions/11004/… for ideas on cleaning up the topology errors. If you wanted to get a close approximation of the reserve area, you could select the reserve polygons, merge them, run buffer on the merged feat (use a buffer dist. > a gap distance you've measured between the farm polygons), toggle "Dissolve result", then run buffer on the dissolved feat using a negative buffer distance that you chose in the first step.
    – cm1
    Feb 5, 2021 at 21:46

There is another option to get rid of the gaps between to polygons. Use the tool Snap geometries to layer form processing toolbox. The trick is to find optimal settings: if tolerance is too high, the tool will affect the polygon boundaries too much, if you set the tolerance too small, you will be left with too many gaps left.

  1. First, open your shapefile and delete all features with area=0 (sort the attribute table accordingly or use select by expression with "AREA" =0).

  2. Than start Snap geometries to layer. An ideal setting when testing was with tolerance 15 m and set Behavior to Snap to anchor nodes (single layer only).

With this two simple steps, you get rid of almost all gaps and invalid geometries. The remaining few can be dealt with manually or using Geometry checker, but depending on which polygons you need to merge, this will not even be necessary.

  • Thank you, this was an even better solution, and I will update my answer accordingly!
    – Stef
    Feb 7, 2021 at 17:37

Downloading your data and merging the selected features as in your screenshot, I got the same sliver polygons/gaps. To get rid of them in an easy way, I applied a buffer of 0.005 m (so that all gaps are covered), than I applied again a buffer, this time of -0.005 m to get to outer boundary back in place.

See the screenshot: the resulting layer with polygons in red outlines and yellow selection of the merged polygon as well as original polygons merged (for the selected features) with the remaining "lines" (in fact gaps) that disappeared form the buffered layer (no red boundary lines): enter image description here

  • Buffering does not affect attributes. But it's always good to check a few random expamples to see how the values were affected. When you merge, in the dialog window you can select a feature/click Take attributes from selected feature. After merging use field calculator, create a new field to calculate the area of the merged, polygons. Or: instead of merging, use the aggregate tool, where you can select for each field how the aggregated value should be calculated: sum, first value, maximum, minimum etc. See: i.stack.imgur.com/nOu8Z.png
    – Babel
    Feb 6, 2021 at 16:27

I had to do a combination of the already proposed solutions:

  1. Toolbox --> Fix geometries (create a new, temporary "fixed_geometry_layer")

  2. Toggle editing (enable it) on the "fixed_geometry_layer" (click on pencil icon)

  3. Select the polygons you want to merge (i.e. I've selected them all)

  4. Edit --> Merge selected features

    if this fails

    a) Toolbox --> Snap geometries to layer on the "fixed_geometry_layer" (create a new, temporary "snapped_geometry_layer"), set tolerance to 15 meters and select "Snap to anchor nodes (single layer only)" behaviour --> go back to point 1)

  5. Do what you need with fields (i.e. I've skipped them all)

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.