mat_geo_dist {graph4lg} | R Documentation |
Compute Euclidean geographic distances between points
Description
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.
Usage
mat_geo_dist(
data,
ID = NULL,
x = NULL,
y = NULL,
crds_type = "proj",
gc_formula = "vicenty"
)
Arguments
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:
|
Details
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.
Value
A pairwise matrix of geographic distances between points in meters
Author(s)
P. Savary
Examples
# 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")