8

I want to create tapered lines with a dashed line stroke (to style intermittent streams). I followed this tutorial to create the taperered lines, basically using Geometry generator with the expression segments_to_lines($geometry) and added the following stroke width expression:

CASE
  WHEN @geometry_part_num < 15 THEN  (0.222750 * (@geometry_part_num / 15))
  ELSE 0.22750
END

The result is as it is supposed to be:enter image description here

But when I style the tapered lines with a dashed line stroke the dashes (and spaces) have very varied lengths (I assume due to segments_to_lines($geometry)):enter image description here For reference, this is how the dashed lines are supposed to look:enter image description here

Does anybody have an idea how I could achieve this effect while having the line tapered?

1
  • 1
    The dash pattern starts over at the beginning of each segment. I don't know of any way to have the pattern continue uninterrupted across multiple segments.
    – csk
    Aug 9, 2018 at 16:10

1 Answer 1

2

This effect occurs because of the different spacing between the line vertices. Try using the Densify by interval tool to make the vertices more evenly spaced on the line. Some test results are shown in the images below.

As commented by @sidapo_cartisan expression may be inserted directly in the geometry generator code: segments_to_lines( densify_by_distance($geometry, distance))

               Original line                            Densified line

1 Line 2 Densified line

3 Line (vert) 4 Densified line (vert)

1
  • Thank you, this works well. For anyone else interested in this: I added the expression directly in the geometry generator code: segments_to_lines(densify_by_distance($geometry,_distance_)) Sep 1, 2022 at 8:51

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.