get_nearestneighbour
Euclidean distance to nearest neighbour
get_nearestneighbour(landscape, return_id) ## S3 method for class 'RasterLayer' get_nearestneighbour(landscape, return_id = FALSE) ## S3 method for class 'RasterStack' get_nearestneighbour(landscape, return_id = FALSE) ## S3 method for class 'RasterBrick' get_nearestneighbour(landscape, return_id = FALSE) ## S3 method for class 'stars' get_nearestneighbour(landscape, return_id = FALSE) ## S3 method for class 'list' get_nearestneighbour(landscape, return_id = FALSE)
landscape |
RasterLayer or matrix (with x,y,id columns). |
return_id |
If TRUE, also the patch ID of the nearest neighbour is returned. |
Fast and memory safe Rcpp implementation for calculating the minimum Euclidean
distances to the nearest patch of the same class in a raster or matrix.
All patches need an unique ID (see get_patches
). Please be aware
that the patch ID is not identical to the patch ID of all metric functions (lsm_).
If return_ID = TRUE
, for some focal patches several nearest neighbour patches
might be returned.
Based on RCpp code of Florian Privé florian.prive.21@gmail.com
# get patches for class 1 class_1 <- get_patches(landscape, class = 2)[[1]] # calculate the distance between patches get_nearestneighbour(class_1) get_nearestneighbour(class_1, return_id = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.