1

I am making a flow map where I want to have a double geometry: a single line and a centered offset arrow line. For the moment, I use a buffer but of course I don't get the desired effect of an arrow of constant length. With the buffer the length of the arrow depends on the segment.

enter image description here

difference(
  difference(
     make_line(
       start_point($geometry),
       centroid(
          offset_curve(
             $geometry, 
             length($geometry)/100.0
          )
       ),
    end_point($geometry)
    ),
    buffer(start_point($geometry), 0.1)
  ),
  buffer(end_point( $geometry), 0.1)

)

enter image description here

1
  • 1
    Can't you use an oriented vector symbol as the (long) arrow? Point geometry as line centroid + offset & orient it with the line azimuth?
    – Kasper
    Apr 18, 2023 at 17:10

2 Answers 2

2

Use Marker Line instead of Geometry Generator. Set the Marker placement to On central point of segments, and set the line offset. Then you can define two symbols inside the marker, first a line like this:

1

And then a triangle like this:

2

The result:

3

1

If I understand your question correctly, you can interpolate the start and end points of your arrow line along the geometry of the feature, insert a mid-point which is offset from those and then offset all of them from the original geometry.

Better explained by this image:

enter image description here

Then add the arrow symbology:

enter image description here

Expression:

offset_curve(  
    make_line(                            -- make a line of the following 3 points
        line_interpolate_point( 
            $geometry,
            length($geometry) / 2 - 50    -- make a point X map units before the midpoint of the line geometry
        ),
        
        line_interpolate_point(
            offset_curve(
                $geometry,
                length($geometry) / 75
            ),
            length($geometry) / 2         -- make a point halfway along the geometry, offset by X map units
        ),
        
        line_interpolate_point(
            $geometry,
            length($geometry) / 2 + 50    -- make a point X map units after the midpoint of the line geometry
        )
    ),
    length($geometry)/100                 -- offset the line from the original geometry
)
Applying the expression

The expression is applied to a Geometry Generator symbol layer as shown here:

enter image description here

You might want the offsets to be a fixed distance, rather than relative to the line length, but that is a design choice that's up to you of course.

Arrow per line segment

If you want the arrow to appear per line segment, rather than for the complete feature, you can use this expression:

collect_geometries(
    with_variable('segments',
        segments_to_lines($geometry),
        
        array_foreach(
            generate_series(1, num_geometries(@segments)),
            
            with_variable('current_segment',
            
                geometry_n(@segments, @element),
                offset_curve(
                    make_line(
                        line_interpolate_point(
                            @current_segment,
                            length(@current_segment) / 2 - 50
                        ),
                        
                        line_interpolate_point(
                            offset_curve(
                                @current_segment,
                                length(@current_segment) / 75
                            ),
                            length(@current_segment) / 2
                        ),
                        
                        line_interpolate_point(
                            @current_segment,
                            length(@current_segment) / 2 + 50
                        )
                    ),
                    length(@current_segment)/50
                )
            )
            
        )
        
    )
)

enter image description here

2
  • Thank you for helping but I am lost in the UI of QGIS. Can you add a screenshot of the symbology window ?
    – Wilcar
    Apr 19, 2023 at 6:05
  • Have done. I hope that is clearer.
    – Matt
    Apr 19, 2023 at 11:31

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.