calc_emd: Calculate EMD

Description Usage Arguments Details Examples

View source: R/wf_basic.R

Description

Calculates Earth-mover's distance for a list of rasters

Usage

1
calc_emd(r_list, mat, check_symmetric = TRUE)

Arguments

r_list

[list] List of r rasterized home ranges to compare.

mat

[matrix] r x r matrix of indicating whether a row-column pair should have its EMD calculated. Can be logical or integer(ish). EMD will be calculated for pairs where mat == TRUE or mat == 1. See details.

check_symmetric

[logical = TRUE] Controls whether function will check for mat for symmetry. See details.

Details

EMD calculations are symmetric, i.e., emd(x, y) == emd(y, x). These calculations are time-consuming, so you will probably want to avoid providing a symmetric matrix. The argument check_symmetric defaults to TRUE and causes the function to stop if your matrix is symmetric so you can correct this before proceeding.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 

# Load data
data(tracks)

# Keep only winter data
winter <- tracks[which(tracks$season == "Winter"), ]

# Split by ID
winter_list <- split(winter, winter$id)

# Calculate a for a-LoCoH
a <- a_default(winter_list)

# Fit LoCoHs
locoh_list <- lapply(winter_list, fit_locoh, n = a)

# Rasterize
r_list <- lapply(locoh_list, rasterize_locoh, res = 500)

# Matrix of comparisons
comp <- matrix(0,
nrow = length(winter_list),
ncol = length(winter_list))

comp[1, 2] <- comp[2, 3] <- comp[3, 4] <- 1

# Calculate EMD
EMD <- calc_emd(r_list, mat = comp)

## End(Not run)

bsmity13/LoCoHverlap documentation built on Feb. 15, 2021, 12:43 p.m.