dist_geographic | R Documentation |
This function calculate some geographical distances considering a list of places specifying their latitud and longitud. The function currently works for degree decimal or radians formats.
dist_geographic(
latitude,
longitud,
method = c("spherical", "harvesine", "manhattan", "minkowski"),
places = NULL,
dd_to_radians = FALSE,
p = NULL
)
latitude |
A vector with latitude |
longitud |
A vector with longitud |
method |
Whether to use the Spherical Law of Cosines |
places |
A vector with the names of the places |
dd_to_radians |
Whether to transform degree decimal format to radians |
p |
Parameter p for the estimation of Minkowski distance (default = 2, which is equivalent to an Euclidian Distance) |
This function return a distance matrix.
Adapted from Mario Pineda-Krch (Great-circle distance calculations in R)
set.seed(1234)
x <- cbind(latitud = rnorm(5, -90), longitud = rnorm(5, 45))
dist_geographic(x[, 1], x[, 2], method = "harvesine")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.