What is @turf/rhumb-bearing?
@turf/rhumb-bearing is a module from the Turf.js library that calculates the bearing between two geographical points along a rhumb line (a line of constant bearing). This is useful for navigation and mapping applications where you need to determine the direction from one point to another.
What are @turf/rhumb-bearing's main functionalities?
Calculate Rhumb Bearing
This feature calculates the rhumb bearing between two geographical points. The code sample demonstrates how to use the `rhumbBearing` function to find the bearing from point1 to point2.
const turf = require('@turf/turf');
const point1 = turf.point([0, 0]);
const point2 = turf.point([10, 10]);
const bearing = turf.rhumbBearing(point1, point2);
console.log(bearing);
Other packages similar to @turf/rhumb-bearing
geolib
Geolib is a library for geospatial calculations. It provides a variety of functions for distance, bearing, and other geographical calculations. Unlike @turf/rhumb-bearing, Geolib offers a broader range of geospatial utilities but may not be as specialized in rhumb line calculations.
geodesy
Geodesy is a library for geodesic and rhumb line calculations. It offers detailed and precise methods for calculating distances, bearings, and other geospatial metrics. Compared to @turf/rhumb-bearing, Geodesy provides more comprehensive geodesic calculations but may be more complex to use.
@turf/rhumb-bearing
rhumbBearing
Takes two points and finds the bearing angle between them along a Rhumb line
i.e. the angle measured in degrees start the north line (0 degrees)
Parameters
start
Coord starting Pointend
Coord ending Pointoptions
Object? Optional parameters
options.final
boolean calculates the final bearing if true (optional, default false
)
Examples
var point1 = turf.point([-75.343, 39.984], {"marker-color": "#F00"});
var point2 = turf.point([-75.534, 39.123], {"marker-color": "#00F"});
var bearing = turf.rhumbBearing(point1, point2);
var addToMap = [point1, point2];
point1.properties.bearing = bearing;
point2.properties.bearing = bearing;
Returns number bearing from north in decimal degrees, between -180 and 180 degrees (positive clockwise)
This module is part of the Turfjs project, an open source
module collection dedicated to geographic algorithms. It is maintained in the
Turfjs/turf repository, where you can create
PRs and issues.
Installation
Install this module individually:
$ npm install @turf/rhumb-bearing
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
6.3.0
Fix issues importing Turf for react-native, webpack 5, and other bundlers
(PR https://github.com/Turfjs/turf/pull/2004 - Author r0b0t3d)
(PR https://github.com/Turfjs/turf/pull/2011 - Author mfedderly)
[@turf/turf
][turf] expose @turf/boolean-intersect
(PR https://github.com/Turfjs/turf/pull/2007 - Author rowanwins)