5

When using

angle_at_vertex($geometry,0)
324.022

in the Field Calculator of QGIS the values seem correct from a visual check. However when using

feature.geometry().angleAtVertex(0)
5.616644978134382

in PyQGIS it returns a different value that doesn't appear to be right.

So far I made sure that the layer's CRS and the project's CRS are the same but I am still getting the same different values. What am I missing out on?

1 Answer 1

11

angle_at_vertex() returns the angle in degrees:

anlge_at_vertex($geometry, 0) -> 38.618825502347555 degree

angleAtVertex() returns the angle in radians:

feature.geometry().angleAtVertex(0) -> 0.674025658269118 radian

For example

38.618825502347555 * pi / 180 = 0.674025658269118

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.