1

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.

7
  • The picture ist showing several lines, that I merged together. They are now a sinlge feature (one single entry in my attribute table) but are still represented as a MultiLine with more than one part, not as Line, as you can see from the multiple centroids on that line. I wish to only have one centroid (the word centroid itself is actually already pretty clear on how many symbol there should be - exactly one).
    – e-shirt
    Commented Nov 16, 2021 at 10:16
  • Do you mean that "the selected line (yellow one) is actually one line in attribute table, but it looks like a multiline because there are several centroids on it, however, it should have been one centroid"? Commented Nov 16, 2021 at 10:23
  • You are in edit mode. After ending the edit mode, the issue remains? Commented Nov 16, 2021 at 10:24
  • 1
    @KadirŞahbaz I assume OP wants to make (Single)LineStrings out of spatially connected MultiLineStrings. You can reproduce this by drawing some connected (Single)LineStrings with snapping enabled, then running dissolve (one single MultiLineString as result) and then multipart-to-singlepart (result where you started instead the spatially connected lines as one single (Single)LineString).
    – MrXsquared
    Commented Nov 16, 2021 at 10:29
  • @MrXsquared is correct. The issue remains after ending editing mode, I had just turned it on to show the line better. The fact that you can still do multipart-to-singlepart shows, that there is still info saved on the old segments. However for me it solves to multiple (Single)LineStrings. How do I delete that info resp. get one (Single)LineString so I can have one centroid?
    – e-shirt
    Commented Nov 16, 2021 at 10:51

3 Answers 3

5
+50

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.

1
  • This is the real deal! I knew there was going to be a way! I used your code line at first and then just had to copy my DDOs to the correct point. Works smooth and actually my map is loading way faster because there are a lot less SVG to load.
    – e-shirt
    Commented Nov 17, 2021 at 15:44
2

In QGIS you have the Merged Features option available something similar to this should bring you the desired result

Merged Features Symbology

I suspect this is how you have it configured at the moment

Single Symbol

1
  • Thank you for that hint, it is well working with simple symbologies. I am however using several data driven overrides, which lead so some strange bugs(?). Now 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. I'll add pictures in my question above.
    – e-shirt
    Commented Nov 17, 2021 at 7:26
0

If you are sure the lines that should be combined are overlapping (i.e. common end vertices) is to edit the original layer and use the "Merge selected features" tool on the "Digitizing tools" toolbar. That will turn the merged lines into a single line. If the dataset is a multiline dataset, you must also make sure all the lines you will combine are pointing in the same direction (easily checked by applying a symbology with asymmetric marker points)

I am also a bit surprised that there is no simple "multipart to single part" tool anywhere.

2
  • Your answer does not answer my question, it's describing the process I did myself to the point when I got here with my problem. Though I doublechecked the details you pointed out. All my lines have the same direction every endpoint is snapped to the startpoint of the next line. My problem to merge all part to one big SingleLineString remains.
    – e-shirt
    Commented Nov 16, 2021 at 12:58
  • I cannot see that you mentioned any other ways that using the Dissolve tool? I was talking about editing the initial layer (although if you are doing a lot of merging into different lines, I agree that that is not a possible way forward-) Commented Nov 16, 2021 at 13:05

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.