# mat_geo_dist: Compute Euclidean geographic distances between points In graph4lg: Build Graphs for Landscape Genetics Analysis

 mat_geo_dist 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 : `data.frame` with 3 columns: 2 columns with the point spatial coordinates and another column with point IDs `SpatialPointsDataFrame` `ID` (if `data` is of class `data.frame`) A character string indicating the name of the column of `data` with the point IDs `x` (if `data` is of class `data.frame`) A character string indicating the name of the column of `data` with the point longitude `y` (if `data` is of class `data.frame`) A character string indicating the name of the column of `data` with the point latitude `crds_type` A character string indicating the type of coordinate reference system: 'proj' (default): a projected coordinate reference system 'polar': a polar coordinate reference system, such as WGS84 `gc_formula` A character string indicating the formula used to compute the Great Circle distance: 'vicenty'(default): Vincenty inverse formula for ellipsoids 'slc': Spherical Law of Cosines 'hvs': Harversine formula

### 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

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")
```

graph4lg documentation built on May 18, 2022, 5:09 p.m.