findvalleys: Find Local Valleys

View source: R/localsurface.R

findvalleysR Documentation

Find Local Valleys

Description

Locates local valleys on a raster or matrix. A valley is defined as any pixel where all 8 surrounding pixels have higher values, and the center pixel has a negative value.

Usage

findvalleys(x)

Arguments

x

A raster or matrix.

Value

A dataframe of local valley 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 and valleys
peaks <- findpeaks(normforest)
valleys <- findvalleys(normforest)

# find top 5 peaks, valleys
top_peaks <- peaks[order(peaks$val, decreasing = TRUE)[1:5],]
bottom_valleys <- valleys[order(valleys$val)[1:5],]

# calculate the ten-point height
S10z <- (sum(top_peaks$val) + sum(abs(bottom_valleys$val))) / 5

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