I am calculating the azimuth between two points whose position is defined in WGS84 coordinates. If I Open Attribute Table -> Open Field Calculator and ask for


I get 95.885 degrees which is inconsistent with the manual calculation atan2(sin(delta_lon)*cos(lat2),cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(delta_lon)), or with the result provided by the French Geographic Institute (geoportail) web site.

However, if following Azimuth calculation, extending lines I run in the Python Console

p1 = QgsPointXY(6.020323,47.248690)
p2 = QgsPointXY(6.083703,47.242157)
d = QgsDistanceArea()

then I get the correct result of 98.584. Could someone enlighten me as to why the first method provides an erroneous result?

Your Answer

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

Browse other questions tagged or ask your own question.