Related to the question line below. How do I make the arrow point to the line correctly ?

This code did not work :

with_variable('myvalue',line_interpolate_angle(geometry:=intersection(buffer(geometry:=$geometry, distance:=50, segments:=3),overlay_nearest(layer:='railways', expression:=$geometry)[0]), distance:=50),if(@myvalue < 180,@myvalue+90,@myvalue-90))

Rotating point layer according to line layer in QGIS

enter image description here

1 Answer 1


For the rotation of the arrow marker, use this expression on the point layer and replace line in line 4 with the name of the line layer.

Explanation: for each point, calculate the azimuth (angle) with the function azimuth() from the initial point ($geometry) to the closest point on the line (to get the line: use overlay_nearest()) with the function closest_point(). Convert radians to degrees with degrees().

        closest_point( overlay_nearest ( 'line', $geometry)[0],

Dotted line for visualization purpose only: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.