Create a weighted co-occurrence matrix (wecoma)

get_wecoma(
x,
w,
neighbourhood = 4,
classes = NULL,
fun = "mean",
na_action = "replace"
)

## Arguments

x A matrix with categories A matrix with weights The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4. A vector or a list with the values of selected classes from the x object. It is used to calculate wecoma only for selected classes. Function to calculate values from adjacent cells to contribute to output matrix, "mean" - calculate average values from adjacent cells of weight matrix, "geometric_mean" - calculate geometric mean values from adjacent cells of weight matrix, or "focal" assign value from the focal cell. Decides on how to behave in the presence of missing values in w. Possible options are "replace", "omit", "keep". The default, "replace", replaces missing values with 0, "omit" does not use cells with missing values, and "keep" keeps missing values.

## Value

A weighted co-occurrence matrix

## Examples

library(comat)
data(raster_x, package = "comat")
data(raster_w, package = "comat")

wom = get_wecoma(raster_x, raster_w)
wom#>      1    2    3
#> 1 12.0  5.0 13.5
#> 2  5.0 12.0 14.5
#> 3 13.5 14.5 49.0
get_wecoma(raster_x, raster_w, classes = list(c(1, 3)))#>      1    3
#> 1 12.0 13.5
#> 3 13.5 49.0