turf.rhumbBearing
What is turf.rhumbBearing?
turf.rhumbBearing returns the bearing along a rhumb line — a path of constant compass heading — between two Point features. It differs from turf.bearing (great-circle) because it assumes the traveller holds a single heading rather than following the shortest geodesic arc.
turf.rhumbBearing(start, end, options?) → numberOptions include:
final—boolean(defaultfalse); whentrue, returns the final rhumb bearing on arrival
When would you use turf.rhumbBearing?
Use turf.rhumbBearing for nautical and aviation flight planning UIs where ships and aircraft historically follow constant headings. It is also the right choice when you want a single bearing to annotate a straight line on a Mercator map — rhumb lines appear straight on Mercator, while great-circle arcs curve.
For orienting icons based on movement, turf.bearing (great-circle) is usually more correct because GPS fixes reflect real movement. Use turf.rhumbBearing when the domain convention explicitly expects rhumb-line math.
undefinedFAQs
How is a rhumb line different from a great-circle?
A rhumb line crosses every meridian at the same angle, so it has a constant heading but is not the shortest path on a sphere. A great-circle is the shortest path but requires continuously changing heading. On a Mercator projection, rhumb lines appear straight; great-circles curve.
Does it accept the `final` option?
Yes — pass { final: true } to get the bearing on arrival rather than the initial bearing. On a rhumb line the heading is constant by definition, so initial and final bearings differ only numerically (initial + 180 mod 360).
How do I install just rhumbBearing?
npm install @turf/rhumb-bearing. It depends on @turf/helpers and @turf/invariant and is a small module.
Which bearing should I use for MapLibre icon rotation?
turf.bearing is generally better — it reflects actual movement between GPS points. Use turf.rhumbBearing when representing navigation conventions (ships, some aviation charts) that explicitly require rhumb-line math.