landscapemetrics (version 1.4.4)

get_nearestneighbour: get_nearestneighbour

Description

Euclidean distance to nearest neighbour

Usage

get_nearestneighbour(landscape)

# S3 method for RasterLayer get_nearestneighbour(landscape)

# S3 method for RasterStack get_nearestneighbour(landscape)

# S3 method for RasterBrick get_nearestneighbour(landscape)

# S3 method for stars get_nearestneighbour(landscape)

# S3 method for list get_nearestneighbour(landscape)

# S3 method for matrix get_nearestneighbour(landscape)

Arguments

landscape

RasterLayer or matrix (with x,y,id columns)

Details

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).

References

Based on RCpp code of Florian Priv<U+00E9> florian.prive.21@gmail.com

Examples

Run this code
# NOT RUN {
# get patches for class 1 from testdata as raster
class_1 <- get_patches(landscape,1)[[1]]

# calculate the distance between patches
get_nearestneighbour(class_1)

# do the same with a 3 column matrix (x, y, id)
class_1_matrix <- raster::rasterToPoints(class_1)
get_nearestneighbour(class_1_matrix)

# }

Run the code above in your browser using DataCamp Workspace