findpeaks: Find Local Peaks

View source: R/localsurface.R

findpeaksR Documentation

Find Local Peaks

Description

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.

Usage

findpeaks(x)

Arguments

x

A raster or matrix.

Value

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.

Examples

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

geodiv documentation built on Oct. 6, 2023, 1:07 a.m.