I have a large river network vector file, where there are disconnections between features. Is there any way to join the nearest dangling points as in the figure below?

river network with dangles

I found there is a plugin "Join Multiple Lines" where we manually select the two lines and then they are joined. There are many such lines that are to be joined, so the manual process is quite not favourable for me.

I also tried the "Geometry by expression" tool in QGIS using>

close_line( $geometry)

but I cannot see any change in the output file.

Does anyone have ways to join this kind of dangling points in the MultiLineString vectors?

  • I think maybe v.clean is what you need per gis.stackexchange.com/a/217977/98784 (old answer). Note I can't always get it to work properly on geopackages or spatialite files with multiple layers in them... best to use a single-layer data source
    – she_weeds
    Jan 3 at 5:21
  • Can you color by category with value $id to it is possible to see if the lines in your screenshot are lines or multilines?
    – BERA
    Jan 3 at 11:00
  • 1
    The screenshot is of multilines but anyway they are going to be exploded for my case. @BERA
    – unknown123
    Jan 3 at 14:31
  • So a multiline looking like a Y you want to connect the top V:s?
    – BERA
    Jan 3 at 16:51

2 Answers 2


You can use "Snap Vertices to Nearest Points by Condition" Processing tool from ProcessX PlugIn.

It is made for this purpose. Before running it, just extract the vertices of your lines via "extract vertices" or "points along geometry", depending on your desired result. Then just choose your desired behavior in "snap vertices" and run it.

For your usecase Snap Endvertices of Geometry may suit. You can also use more than one snapping option, e.g. if you also want to snap the ends of multiline parts. You can also choose a maximum snapping distance and an attribute condition, so only the lines with e.g. the same name snap to each other, even if there are other lines within that tolerance distance. As a second condition you could choose that the lines should have a different ID, so they dont snap to a vertex belonging to itself even if they have the same name.

enter image description here

Example result:

enter image description here

Disclaimer: I am the author of this tool.

  1. Extract start- and end-points of the lines using Menu Processing > Toolbox > Geometry by expression with this expression: union (start_point ($geometry), end_point($geometry)), then run Multipart to Single parts.

  2. Connect each point to the closest point, respecting a maximum distance to get only those connections you want. Use this expression:

    make_line (
            max_distance:=2000 -- change this value to fit your needs

Hint: First use Geometry generator with the same expression. Like this, you can manually adapt the distance in line 6 (here: 2000) and see in realtime how the line changes. This way, you can find the ideal length, then run Geometry by expression with this value.

Expression with Geometry generator: initial line in blue, with start- end end-points (red) and connecting lines (light red): enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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