I have the following simple piece of code to find the position between two coordinate points using linear interpolation. I’m not sure if this is a good / feasible solution or not. So what do you think?

Linear interpolation of the coordinates will only be approximately correct for points that are near each other, and it fails completely if you cross the date line. For larger distances you need to account for the curvature of the earth by calculating the great circle distance - and for that you need to use spherical trigonometry (instead of ordinary planar). The standard approach for lat-lon coordinates is to use the haversine formula, or alternatively n-vectors. Then I guess you could just interpolate the two altitudes if that makes sense for your application.

I don’t think we have a registered julia package which can do this in the most natural way yet. The obvious candidates would be Proj4.jl (wraps the C proj.4 library) and Geodesy.jl (pure julia, with some algorithms ported from GeographicLib). This may eventually be in Geodesy.jl (see https://github.com/JuliaGeo/Geodesy.jl/issues/40) but in the meantime you could try out https://github.com/anowacki/GeographicLib.jl or Proj4.jl with a similar two-step procedure:

Compute the azimuth and great circle distance along the geodesic from the first to second point using GeographicLib.inverse or Proj4.geod_inverse

Interpolate along this geodesic from the first point toward the second using GeographicLib.forward or Proj4.geod_destination.

All the above is for interpolating the lat-lon components. For the altitude you can probably just use linear interpolation based on the fractional distance along the geodesic.

Thanks for giving that explanation, @Chris_Foster. That is indeed how I would do this. GeographicLib.jl now also exposes the waypoint functionality of the original library with waypoints, though this doesn’t include fractional distances. (Perhaps an additional option could be added.)

As Chris says, this should be added to Geodesy if I can get round to it at some point this coming semester.

The Haversine method suggested by Niclas is for great circles on the sphere, so if the accuracy you need is not high, or you are only interested in spheres, that will do the job fine. (Feel free to steal the implementation of delta and step in https://github.com/anowacki/assorted-julia-modules/blob/master/SphericalGeom.jl). If accuracy on the real Earth is required, the other routes explained above with Proj or GeographicLib are needed.

I was not sure of this but checked, GMT only does this on the sphere. If that’s enough, with the master version, to interpolate at 5000 km steps along a line from long, lat (0,0) to (45,45)