Description Usage Arguments Details Value Warning Author(s) Examples
Calculates the geographic distance (in kilometers) between a reference point and a set of coordinates using the Haversine formula (great-circle distance).
1 | geoDist(ref, coords)
|
ref |
The reference Latitude and Longitude coordinates used as the 'starting point' for the geographic distance measure. |
coords |
The Latitude and Longitude coordinates representing the 'end point' for the geographic distance measure. |
More than one value can be supplied to the coords
data frame. See example below.
A numeric value in kilometers between the reference point and each point in coord
It is assumed the coordinates will have column names matching "Latitude" and "Longitude". If these column names are not found the function will fail. Use colnames(x) <- c("Latitude", "Longitude")
to change the column names, where x
is the data frame
P. A. Harrison
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # set up the 'ref' data frame
tmp0 <- data.frame(Longitude = 147.4686, Latitude = -42.008)
# set up the 'coord' data frame
tmp1 <- data.frame(Longitude = 147.1541, Latitude = -41.8339)
# run the function
PUCA::geoDist(tmp0, tmp1)
# geoDist
# 1 32.47
#not ran
#set up red and coord in same data frame
tmp <- rbind(tmp0, tmp1)
#run the function
#PUCA::geoDist(tmp[1,], tmp[2,])
# geoDist
# 1 32.47
# set up the 'coord' data frame with more than one point
tmp1 <- data.frame(Longitude = c(147.1541, 147.457063), Latitude = c(-41.8339, -41.980778))
# run the function
geoDist(tmp0, tmp1)
# geoDist
# 1 32.47
# 2 3.18
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.