| mat_geo_dist | R Documentation |
The function computes Euclidean geographic distance between points given their spatial coordinates either in a metric projected Coordinate Reference System or in a polar coordinates system.
mat_geo_dist( data, ID = NULL, x = NULL, y = NULL, crds_type = "proj", gc_formula = "vicenty" )
data |
An object of class :
|
ID |
(if |
x |
(if |
y |
(if |
crds_type |
A character string indicating the type of coordinate reference system:
|
gc_formula |
A character string indicating the formula used to compute the Great Circle distance:
|
When a projected coordinate reference system is used, it calculates
classical Euclidean geographic distance between two points using
Pythagora's theorem. When a polar coordinate reference system is used, it
calculates the Great circle distance between points using different methods.
Unless method = "polar", when data is a data.frame,
it assumes projected coordinates by default.
A pairwise matrix of geographic distances between points in meters
P. Savary
# Projected CRS
data(pts_pop_simul)
mat_dist <- mat_geo_dist(data=pts_pop_simul,
ID = "ID",
x = "x",
y = "y")
#Polar CRS
city_us <- data.frame(name = c("New York City", "Chicago",
"Los Angeles", "Atlanta"),
lat = c(40.75170, 41.87440,
34.05420, 33.75280),
lon = c(-73.99420, -87.63940,
-118.24100, -84.39360))
mat_geo_us <- mat_geo_dist(data = city_us,
ID = "name", x = "lon", y = "lat",
crds_type = "polar")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.