Calculating bearing between 2 GPS points

6311
5
02-27-2019 10:50 AM
LondonTransit
New Contributor

I am trying to calculate the bearing between 2 different points - Lat1, Long1 & Lat2, Long2.  I have researched many formulas and python scripts but cannot seem to accurately determine the bearing.  I found that ArcGIS has a Production Mapping license which contains a tool that can do the work for me, but would rather attempt other option first. 

Is there an easier way without inquiring about another license to achieve the bearing between 2 points?

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

is Haversine not good enough?

Haversine Formula in Python (Bearing and Distance between two GPS points) - Stack Overflow 

I have implemented Vincenty's approximation

Vincenty's formulae - Wikipedia 

in Python, but it isn't suitable for field calculator calculations since it is iterative.  It can be used in a python ide with the user providing long/lats pairs, if you are interested? (not much market for a tool to do this) or you could construct lines and calculate the bearings yourself using

Calculate Geometry Attributes—Data Management toolbox | ArcGIS Desktop 

MelindaMorang
Esri Regular Contributor

If you're working with python PointGeometry objects, there's a method called angleAndDistanceTo that can be used to calculate the bearing from one point to the next.

PointGeometry—ArcPy classes | ArcGIS Desktop 

LondonTransit
New Contributor

Thanks for the help!  I ended up using the Haversine Formula in Python which is calculating the proper bearing between stops.  Now my only issue is that I need to calculate the bearing for roughly 1000 pairs of GPS points....It would be great if I could enter it into the Field Calculator, however like you said that is not possible.

Any suggestions on how to batch this process for a number of records? 

0 Kudos
DanPatterson_Retired
MVP Emeritus

Vincenty is iterative, not haversine.,

0 Kudos
DanPatterson_Retired
MVP Emeritus

Maybe you can cobble up something with this

vincenty.py · GitHub 

It was actually way faster than doing geodesic calculations using arcpy pointgeometry objects

0 Kudos