Calculates an average distance between non-NA cells

get_distance(p, x)

Arguments

p

A matrix

x

A SpatRaster with proper metadata (e.g., extent and CRS)

Value

An average distance between points

Details

It converts permuted matrix into a vector dataset, and calculates an average distance between the points