QGIS LineString Conversion – How to Convert MultiLineString to One LineString

centroidslinestringmarkersqgissymbology

TLDR: I was not able to change the String type from MultiLineString to LineString and keep the line together but there is a way to still represent that as a symbology. So my problem is solved, but the main problem still remains.


In QGIS, I have a line shapefile.
I have merged several lines using the simple merge tool (merge selected features) or the dissolve tool. The lines get merged properly, but they get merged as a MultiLineString.

When now using a symbology with middlepoint markers, still every part of that MultiLineString gets a middlepoint marker:

a MulitLineString with several segments, all represented with a marker

How do I manage to get only one midlepoint per feature by either

  • changing something in my symbology, that I have missed out on or
  • changing the layer properties or the feature itself from MultiLineString to LineString?

I have found this post, but that only solves converting one MultiLineString to several LineStrings. I need my line stay as one feature to make my symbology work.

This is a brief overview of my layer styling:

I use several data driven overrides for line color, line style (hash) and for marker size and which marker gets chosen.

Using the "Merged features" option in layer symbology together with DDO leads to some weird misrepresentations on my map. Depending on the scale, all lines get only one same symbology. I can not estimate, what factors decide, which of the several linecolors and markers I have gets chosen.

The lines from my upper picture on a smaller scale:

On about the same scale:

And on a scale in between:

Also, there are still markers on every segment of my merged line.

I know this is quite a complex symbology I am aiming for, but I don't see where it shouldn't technically be possible to achieve.

I'm using QGIS 3.22.0 on Windows 10.

Best Answer

You can use the Geometry Generator symbol type:

MultiLineString layer with mid point symbology

Choose Point as Geometry type, and type line_interpolate_point( $geometry, length($geometry)/2) in the expression field to generate a point in the mid point of your multilinestring features.