# import raster image
data(normforest)
normforest <- terra::unwrap(normforest)
# locate peaks
peaks <- findpeaks(normforest)
# calculate the summit density (# peaks/area)
N <- ncol(normforest)
M <- nrow(normforest)
Sds <- nrow(peaks) / ((N - 1) * (M - 1))
Run the code above in your browser using DataLab