findvalleys | R Documentation |
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.
findvalleys(x)
x |
A raster or matrix. |
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.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.