calc_bearing: Calculate bearing from one location to another

Description Usage Arguments Details Value

View source: R/latlon_helpers.R

Description

Calculates the bearing of a second location, as seen from the first location, based on latitude and longitude coordinates for both locations.

Usage

1
calc_bearing(tclat_1, tclon_1, tclat_2, tclon_2)

Arguments

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.

Details

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:

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.

Value

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.


stormwindmodel documentation built on July 27, 2020, 9:06 a.m.