2

Given two GPS points A and B, I would like to compute the GPS coordinates A1 and A2. [A1A2] forms a segment perpendicular to segment [AB]. gps For this, I start to compute M1, which is the midpoint of [AB] and should be the midpoint of [A1A2].
The distance [A1M1] = [M1A2] = d
My approach consists of finding the distance from A to B using the haversine formula.

from haversine import haversine

A = (lat1, lon1)
B = (lat2, lon2)

dist = haversine(A, B)

Then I get half of it.

half_dist = dist/2

After that, I find the GPS coordinate M1 located on segment [AB], which distance |AM1| = half_dist For that, I use the approach proposed on this post.

from geographiclib.geodesic import Geodesic
#Define the ellipsoid
geod = Geodesic.WGS84

#Solve the Inverse problem
inv = geod.Inverse(A[0],A[1],B[0],B[1])
azi1 = inv['azi1']

#Solve the Direct problem
dir = geod.Direct(A[0],A[1],azi1,half_dist)
M1 = (dir['lat2'],dir['lon2'])

My difficulty starts here. I don't know how to go on to calculate the coordinates of points A1 and A2 given the distance d.

How can I do this?

2
  • Why don't you use coordinates as if in Cartesian? Since the area you are working in is very small, the error will be too small to be ignored, unless you're working with millimeter precision. Commented Mar 20, 2022 at 10:23
  • Thank you @KadirŞahbaz, I will do that, a gap of about 1 meter will not be a problem for me.
    – Kyv
    Commented Mar 20, 2022 at 10:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.