Description Usage Arguments Details Value
View source: R/latlon_helpers.R
Calculates the bearing of a second location, as seen from the first location, based on latitude and longitude coordinates for both locations.
1 | calc_bearing(tclat_1, tclon_1, tclat_2, tclon_2)
|
tclat_1 |
A numeric vector giving latitude of the first location (degrees) |
tclon_1 |
A numeric vector giving longitude of the first location (degrees). This value should be expressed as a positive value for Western hemisphere longitudes. |
tclat_2 |
A numeric vector giving latitude of the second location (degrees) |
tclon_2 |
A numeric vector giving longitude of the second location (degrees). This value should be expressed as a positive value for Western hemisphere longitudes. |
This function uses the following equations to calculate the bearing from one latitude-longitude pair to another:
S = cos(φ2) * sin(L1 - L1)
C = cos(φ1) * sin(φ2) - sin(φ1) * cos(φ2) * cos(L1 - L2)
θ = atan2(S, C) * \frac{180}{π} + 90
where:
φ1: Latitude of first location, in radians
L1: Longitude of first location, in radians
φ2: Latitude of second location, in radians
L2: Longitude of second location, in radians
S, C: Intermediary results
θ: Direction of the storm movement, in degrees
In cases where this equation results in values below 0 degrees or above 360 degrees, the function applies modular arithmetic to bring the value back within the 0–360 degree range.
A numeric vector giving the direction of the second location from the first location, in degrees. A direction of 0 degrees indicates the second location is due east of the first, 90 degrees indicates the second location is due north of the first, etc.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.