# Calculate angle between nodes or point in line in QGIS

I want to check the digitization of line in correct direction, so for that I need to know the angle of each node in line. Is that possible in QGIS?

There is the `angle_at_vertex(geometry,vertex)` fonction in field calculator that

Returns the bisector angle (average angle) to the geometry for a specified vertex on a linestring geometry. Angles are in degrees clockwise from north.

But you have to specify at witch vertex the angle is to be calculated, if you want to check the whole line you probably need to create a script that calculate angle for each vertex from start to end then compare the successive value to your requirement.

I think you are asking for the angle in which two lines make when intersecting.

When two lines intersect they create two unique angles. One obtuse and one acute (unless they are the same).

Calculate the polar angle of both the lines.

Polar angle

The polar angle is the counterclockwise angle from the x-axis at which a point in the xy-plane lies.

Find the difference between theses two angles.

This will give you either the acute angle or the obtuse angle.

Here is some Python code to help understand how to calculate these values.

``````import numpy as np

def get_angle(line):
p1 = line.firstPoint
p2 = line.lastPoint
y = p1.Y-p2.Y
x = p1.X-p2.X
if x == 0:
if y > 0:
angle = np.pi/2
else:
angle = (-1)*np.pi/2
else:
angle = np.arctan(y/x)
angle = np.degrees(angle)
return angle

def get_acute_angle(a1, a2):
angle = np.abs( a1 - a2 )
if angle > 90:
angle = 180 - angle
return angle
``````