watex.utils.get_bearing#
- watex.utils.get_bearing(latlon1, latlon2, to_deg=True)[source]#
Calculate the bearing between two points.
A bearing can be defined as a direction of one point relative to another point, usually given as an angle measured clockwise from north. The formula of the bearing \(eta\) between two points 1(lat1 , lon1) and 2(lat2, lon2) is expressed as below:
\[eta = atan2(sin(y_2-y_1)*cos(x_2), cos(x_1)*sin(x_2) – sin(x_1)*cos(x_2)*cos(y_2-y_1))\]where:
- Parameters:
latlon (Tuple ( latitude, longitude)) – A latitude and longitude coordinates of the first point in degree.
latlon2 (Tuple ( latitude, longitude)) – A latitude and longitude of coordinates of the second point in degree.
to_deg (bool, default=True) – Convert the bearing from radians to degree.
- Returns:
b (Value of bearing in degree ( default).)
See More
———-
See more details by clicking in the link below – https://mapscaping.com/how-to-calculate-bearing-between-two-coordinates/
Examples
>>> from watex.utils import get_bearing >>> latlon1 = (28.41196763902007, 109.3328724432221) # (lat, lon) point 1 >>> latlon2= (28.38756530909265, 109.36931920880758) # (lat, lon) point 2 >>> get_bearing (latlon1, latlon2 ) 127.26739270447973 # in degree