Linear interpolation to find a GPS location (latitude, longitude) between two given GPS locations (latitudes, longitudes) using Julia

I know how to do the following basic algebra calculation to find the y-value, say y_0 of a intermediate point corresponding to a given t_0 in a straight line from point (t_1, y_1) to (t_2, y_2). My question is, does it make sense to use the similar method to find the intermediate GPS location point (latitude, longitude) between two given GPS location point (latitude, longitude), since both latitude and longitude are angles, not coordinates.

1 Like

This isn’t really a Julia specific question if I understand correctly, are you looking for something like Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript?

3 Likes

thank you for your kind reply. :wink:

Maybe this can help. The GMT’s project module does let you compute coordinates between two points at an equal distance in km (or meters). Sorry, I’ve not yet ported this module to a more verbose syntax, so need to use option letter like in GMT command line (not the Julia version) syntax. This example (from project man page).

# To generate points every 10km along a great circle from 10N,50W to 30N,10W:
using GMT
D = project(C=(-50,10), E=(-10,30), G=10, Q=true)
1-element Array{GMT.GMTdataset,1}:
 GMT.GMTdataset([-50.0 10.0 0.0; -49.9244 10.0504 10.0; … ; -10.0835 29.974 4690.0; -10.0 30.0 4698.55], String[], "", String[], "", "")
1 Like

@pszufe

Hi, I was checking on the formula from the link you provided to calculate the intermediate point along any great circle path between two given points. One point confuses me. What is exactly the meaning of “angular distance d/R between the two points”? If I understand it correctly, d would be the distance between the two given points and R would be the earth’s radius? Is this correct?

The link given by nilshg explicitly states that R is the earth’s radius, but doesn’t state what d is, I guess. But his link further links to Wikipedia (https://en.wikipedia.org/wiki/Haversine_formula), where one can infer that c in the link is the central angle (\Theta in Wikipedia), and that in fact, d is the distance between the two points along the great circle.

2 Likes

You could use geopy via PyCall to calculate the distance.
If you want to port some code of GeoPy to Julia (perhaps to OpenStreetMapX or as a separate project) that would also be great.

You could start with trying to use ECEF coordinate system (converting between LLA and ECEF) - this would make such computation that you need easy:

julia> using OpenStreetMapX

julia>  north_pole=LLA(90,0,0)
LLA(90.0, 0.0, 0.0)

julia> ECEF(north_pole)
ECEF(0.0, 0.0, 6.356752314245179e6)     #Earth radius