Python for GPS Coordinates – Finding Point X-Distance between Two Coordinates

coordinatesgpspython

I have 2 pairs of GPS coordinates A = (44.27364400,-121.17116400) and B = (44.27357900, -121.17006800) and a distance of 10m. I'm trying to find the GPS coordinates of the point that's 10m from A toward B. I know I can use haversine to find the distance between A and B coutesy of: https://stackoverflow.com/a/4913653/5369777 is there someway I can add or subtract the distance 10m to return the degrees for the new point?

Best Answer

Charles Karney wrote the powerfull GeographicLib program to solve all of this problems.

You can install the geographiclib Python package, it comes as a dependency with geopandas too.

from geographiclib.geodesic import Geodesic

A = (44.27364400, -121.17116400) #Point A (lat, lon)
B = (44.27357900, -121.17006800) #Point B (lat, lon)
s = 10 #Distance (m)

#Define the ellipsoid
geod = Geodesic.WGS84

#Solve the Inverse problem
inv = geod.Inverse(A[0],A[1],B[0],B[1])
azi1 = inv['azi1']
print('Initial Azimuth from A to B = ' + str(azi1))

#Solve the Direct problem
dir = geod.Direct(A[0],A[1],azi1,s)
C = (dir['lat2'],dir['lon2'])
print('C = ' + str(C))

Returns:

Initial Azimuth from A to B = 94.71831670212772
C = (44.27363659722271, -121.17103916871612)