6

I want to merge lines and fill the gaps between them, but I cannot use the "Join multiple lines"-Plugin because I have to use the Graphical Modeler and in there is the plugin/tool not available. Does anyone know another approach?

example line with gap

1
  • I added a picture. If I use the merge lines tool it does not fill the existing gaps between the lines if I am not wrong? Commented Oct 27, 2022 at 11:14

2 Answers 2

6

Extract start and end points with "Geometry by expression" start_point($geometry) and end_point($geometry) as two separate point layers.

Execute "Shortest line between features" twice, with a "Maximum distance" set, one from start to end points, and one for end to start points.

"Merge" the two shortest line layers.

"Delete duplicate geometries".

If you want to - merge the resulting layer with your input layer, I haven't

enter image description here

5
  • looks great thank you, but can I integrate this in a graphical model builder workflow? Commented Oct 28, 2022 at 14:12
  • 1
    I've created a new workflow which you can use in modeler
    – Bera
    Commented Oct 28, 2022 at 17:16
  • 1
    thank you so much! you helped me a lot! Commented Oct 31, 2022 at 8:07
  • Actually I cant find the: "shortest line between" algorithm... At first I thought you renamed another algorithm in the graphical modeler, but I cant find another one with the same functions. Im am using QGIS 3.22.10 by the way Commented Oct 31, 2022 at 11:26
  • It is called Shortest line between features, I have v. 3.26
    – Bera
    Commented Oct 31, 2022 at 11:33
2

Try this workflow for the following input

input

Step 1. Use the "Add autoincremental field" tool

step1

x(centroid($geometry)) was applied for 'Sort expression'

Step 2. "Extract vertices"

step2

Step 3. Apply the "Points to path" geoalgorithm

step3

"AUTO" || "vertex_index" was used in 'Order expression' and "id" as 'Path group expression'

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.