Skip to contents

Pair geographic distances between sites with community dissimilarities (Sorensen index computed as binary Bray-Curtis) for distance-decay plots.

Usage

calculate_distance_decay(
  abund_matrix,
  site_coords,
  metric = c("auto", "euclidean", "along_path")
)

Arguments

abund_matrix

A site x species abundance data frame where the first column is site and the remaining columns are abundances.

site_coords

A data frame with numeric columns x and y giving site coordinates (in a projected CRS) in the same row order as abund_matrix.

metric

Character scalar. One of:

  • "auto" (default): use along-path distance if a graph distance matrix or site_coords$linear_pos exists, else Euclidean.

  • "euclidean": force Euclidean distance on x,y.

  • "along_path": use absolute differences in site_coords$linear_pos; if linear_wrap attribute is TRUE, use wrapped circular distance. If attribute attr(site_coords, "graph_dist_matrix") is present, that matrix is used instead.

Value

A data frame with two numeric columns:

Distance

Euclidean distance between site pairs.

Dissimilarity

Sorensen dissimilarity (0-1).

Examples

if (FALSE) { # \dontrun{
dd <- calculate_distance_decay(abund_matrix, site_coords)
head(dd)
} # }