8

I have two polygon layers in QGIS 3.4: 'Layer A' and 'Layer B'. These two layers have been digitized separately. Some features in these two layers are crossing or not meeting each other in some areas which I have to fix this problem.

'Layer A' is an accurate layer in terms of boundary so I want all the features in 'Layer B' be snapped to the closest feature (point) in 'Layer A'.

Currently I try to move and snap all the vertexes in 'Layer B' to 'Layer A' manually using digitizing tool in QGIS which is very time consuming and I might miss some of them

So my question is: How can I do this process automatically or at least semi automatic?

3
  • Does this help docs.qgis.org/2.14/en/docs/user_manual/plugins/… ? Commented Oct 30, 2019 at 0:50
  • @MichaelStimson This is for QGIS 2.14 and I can't find it in QGIS3.4 do you know anything similar for QGIS 3.4?
    – Shiva
    Commented Oct 30, 2019 at 1:29
  • 4
    How about "Snap geometries to layer" in the "Vector geometry" algorithms section of Processing Toolbox?
    – Ben W
    Commented Oct 30, 2019 at 1:41

1 Answer 1

5

There are at least two possible solutions:

1. Use Geoprocessing / Difference

A simple approach is to create a buffer around layer B - set the buffer distance high enough that all white spaces between the two layers are covered. See screenshot: Layer A: orange; Layer B: blue; buffered Layer B: red outline.

enter image description here

Now use Menu Vector / Geoprocessing Tools / Difference and set the buffer layer as input and Layer A as Overlay layer. You get a perfectly fitting version of layer B, with layer A unchanged:

enter image description here


Snap vertices of layer B to nearest vertex of layer A

For QGIS 3.16 or higher, there is another option. You can use basically the same procedure as described here:

The idea is to create two points layer, representing the vertices of the two polygon layers using Menu Vector / Geometry Tools / Extract vertices. Than "snap" the points of layer B to the closest point of layer A using the new overlay_nearest expression, see visual changelog. Create a new point layer with Menu Processing / Toolbox / Geometry by expression and this expression, based on input layer B:

array_first (
    overlay_nearest( 
        'layer_A', 
        $geometry
    )
)

Than connect the points using Menu Processing / Toolbox / Points to path` and from these path create a polygon with Menu Vector / Geometry Tools / Lines to polygons.

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.