4

I have a line(multiline) layer in QGIS 3.22. I need to place a point in the middle.

I've tried using the algorithms: "interpolate point on line" and "points along geometry", by using as distance the expression $length/2. Both work fine with lines but not with multilines.

Is there any other algorithm or easy way to do it? (I'm not a programmer) Or, how can I convert the multiline to a string line to use this algorithms? (not single lines)

Taras
  • 32,823
  • 4
  • 66
  • 137
david
  • 103
  • 4

1 Answers1

5

line_interpolate_point($geometry,$length/2), respectively $length/2 should work fine, see:

enter image description here

Note that MultiLineStrings do not necessarily have a logical order of their paths, so the center of it may lay somewhere else than you excpect, just as in my image. The red labels indicate the part number and the arrow the line/parts direction. You could try to combine the order_parts() expression together with the above, if you can find some suiting order logic.

If you prefer single parts you can run "Multipart to singleparts" from processing toolbox.

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
  • In most cases it works fine. Much better than the algorithms in my question. And how to convert the multiline in a stringline? – david Oct 10 '22 at 19:01
  • you can run "Multipart to singleparts" from processing toolbox. – MrXsquared Oct 10 '22 at 19:03
  • It does'nt work: it converts the multiline to single lines. I need the polyline to work. – david Oct 10 '22 at 19:10
  • Please define "stringline". – MrXsquared Oct 10 '22 at 19:15
  • Each multiline entity has X segments. When converting with "multiline to single parts" I get X single entities from each multiline. I would need a different kind of entity than the multiline but with the same X segments to work. If the previous is not possible, can you tell me how to use the order_parts() in your previous code? – david Oct 10 '22 at 19:20