3

I am trying to animate a point moving from one location to another on a map. And I would like the point to travel along the great circle arc between the locations, rather than in a straight line.

Given the starting coordinates (lng/lat) and the ending coordinates, is there a formula for interpolating along the great circle arc to get the point's coordinates at each step in its route.

I need to run this calculation on the fly (in a WebGL shader), so I can't use PostGIS or a GIS application. It needs to be a formula or algorithm.

  • 1
    Calculating the partial differential equation is an iterative algorithm, documented in many, many places. I'd recommend using a code library instead of coding it from scratch from the working manual. – Vince Feb 27 '17 at 1:55
3

You can use GeographicLib, which has bindings to several programming languages. For example, the JavaScript version has an example to compute waypoints between two points.

Essentially, you create an inverse geodesic line between the two locations, then generate as many points (either total number or interval distance) between the two points along the geodesic line.

  • 1
    If your display isn't in pseudo-plate carree (aka you're just mapping lat-lon points as if they're 2D, you'll also have to project the points to whatever projected CRS the map is using (Web Mercator?). – mkennedy Feb 28 '17 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.