geoprimsField-grade geospatial math

Closest point on a route

The point on a multi-leg route closest to a position: which leg, how far along the route, and how far off it (right of course positive).

Planning and education aid. Not for primary navigation. Full disclaimer

2

The closest point is on leg 2, 140.918 km along the route and 8.477 km off it.

Along the route
Off the route
Closest point latitude
Closest point longitude
Route length
Provenance
Computed by
navigation.route.closest-point 1.0.1, core 0.1.0
Model
Closest point on each geodesic leg by Karney's interception method, on WGS 84
Accuracy
Within 1 mm, like the cross-track tool
Notes
None
Cites
Karney, C. F. F., Journal of Geodesy, Algorithms for geodesics

Something look off?

Your values

Showing an example. Change anything.
KML, KMZ, GPX, GeoJSON, CSV, WKT, or WKB — or drop it on the box. Read on this device.
More options 2
Run many at once from a CSV

Loading…

How we got thisFormula, worked example, sources, and proof

Model: Closest point on each geodesic leg by Karney's interception method, on WGS 84

Accuracy: Within 1 mm, like the cross-track tool

When to use this: Use this when the course is a whole route rather than one leg: to say which leg a position belongs to, how far along the route its closest point lies, and how far off the route it is. It is the tool for placing a reported position, a diversion, or a point of interest against a filed plan, and for measuring how far a flown track wandered from it.

Limitations: It measures to the route line itself, not to a corridor or an airway's protected width, and the cross-track sign is right of course on the leg it chose, so the sign flips at a turn. Where two legs are nearly equidistant, as inside a sharp turn, the leg reported is the nearer by geometry and may not be the one being flown. A closest point that falls past the end of a leg is reported as that waypoint, which is correct as a distance but means the answer is a corner rather than a perpendicular. A leg a quarter of the Earth or more away is skipped, keeping its length in the total but never holding the answer. Heights play no part, and the route is geodesic legs, not rhumb lines.

Worked example: A position beside the second leg of a five-leg route. Source: GeographicLib 2.7 GeodSolve: the closest point sits where the course to the position is 90.00000000000 from the leg, 8476.774536 m away, with the first leg and the run up to it summing to the along-route distance. It is golden test vector v023, and every build checks the tool still gives its answer within its tolerance.

You enter

Position latitude
40.5 deg
Position longitude
-103.9 deg
Route
40, -105 40, -104 41, -104 41, -103 40, -103 40, -102

You get

Leg
2
Along the route
140.918 km
Off the route
8.477 km
Closest point latitude
40.5000433°
Closest point longitude
-104°
Route length
477.01 km

Review: Not yet independently reviewed by a geodesist.

Last verified: 2026-09-18, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.1, core 0.1.0. See this tool in the verification report.

Changes

Checked against: 23 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources