findpeaks | R Documentation |
Locates local peaks on a raster or matrix. A peak is defined as any pixel where all 8 surrounding pixels have lower values, and the center pixel has a positive value.
findpeaks(x)
x |
A raster or matrix. |
A dataframe of local peak locations (x, y
) and
values (val
). The raster or matrix location index (ind
),
row (row
), and column (col
) are also listed.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.