latlon_to_km: Calculate distance between two locations

Description Usage Arguments Details Value

View source: R/latlon_helpers.R

Description

This function takes latitudes and longitudes for two locations and calculates the distance (in meters) between the locations using the Haversine method.

Usage

1
latlon_to_km(tclat_1, tclon_1, tclat_2, tclon_2, Rearth = 6378.14)

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.

Rearth

Radius of the earth (km). Default is 6378.14 km.

Details

This function uses the Haversine method with great circle distance to calculate this distance. It is applying the following equations to determine distance (in kilometers) between two latitude-longitude pairs:

hav(γ) = hav(φ1 - φ2) + cos(φ1)*cos(φ2)*hav(L1 - L2)

where:

Value

A vector with the distance between the two locations, in kilometers.


geanders/stormwindmodel documentation built on Oct. 15, 2018, 12:06 p.m.