
Pairwise geographic or elevational distances
geo_distance.RdGreat-circle (haversine) or elevational distances between sites, as a
long tibble ready to join with tidydiversity::beta_pair() or to build
a geo_decay() distance-decay table. Elevational distance is the absolute
difference in metres.
Arguments
- data
A data frame of unique sites (or records constant within site) with coordinates and optional elevation.
- lon, lat, elevation, site
<
data-masking> Column selections.- method
"haversine"(metres),"elevation"(metres),"euclidean"on lon/lat in degrees, or"environmental"for Euclidean or Gower distance on numeric covariate columns (for example bioclim layers fromgeo_extract()/geo_bioclim()).- vars
Character vector of covariate columns for
method = "environmental". WhenNULL, every numeric column except coordinates, elevation and the site id is used.- scale
Standardise environmental columns to mean 0 and sd 1 before Euclidean distance? Ignored for Gower.
- metric
"euclidean"or"gower"for environmental distances.- .by
Optional grouping columns.
Examples
sites <- tibble::tibble(
site = c("a", "b", "c"),
lon = c(147.0, 147.1, 147.2),
lat = c(-9.4, -9.5, -9.6),
elevation = c(200, 700, 1200)
)
geo_distance(sites, lon, lat, method = "haversine")
#> # A tibble: 3 × 3
#> site_1 site_2 distance
#> <chr> <chr> <dbl>
#> 1 a b 15619.
#> 2 a c 31236.
#> 3 b c 15617.
geo_distance(sites, elevation = elevation, method = "elevation")
#> # A tibble: 3 × 3
#> site_1 site_2 distance
#> <chr> <chr> <dbl>
#> 1 a b 500
#> 2 a c 1000
#> 3 b c 500