I would like to get an average azimuth of a route (like slope in linear regression).

I tried using linear regression to calculate a slope and convert that slope to degrees (azimuth), but I got the wrong result. The reason is probably that I used geographic coordinates (lon, lat degrees) as an input.

Should I convert coordinates to some projected coordinate system that preserves correct angles? Maybe Azimuthal Equidistant or Lambert Azimuthal Equal Area projection? And use these coordinates in linear regression calculation?

Or is there another way to calculate the average azimuth of a route?


1 Answer 1


I think I found a solution. I'm still using geographic coordinates for linear regression input, but instead of trying to convert the resulting slope directly to azimuth, I'm using it to calculate a second point of the avg. line.

lonDelta = maxLon - centerLon;
latDelta = slope * lonDelta;

p1 = (centerLon, centerLat);
p2 = (centerLon + lonDelta, centerLat + latDelta);

And then I calculate the azimuth between p1 and p2. Input values for lonDelta might not be optimal, but overall it seems that result are good enough.

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.