area_above: Area Above the Bearing Area Curve

View source: R/simpsons.R

area_aboveR Documentation

Area Above the Bearing Area Curve

Description

Calculates the area above the bearing area curve from points a to b. If a box is drawn around a function with the upper-left at a and the bottom-right at b, this function extracts the area above the function within the box.

Usage

area_above(f, a, b, n = 100)

Arguments

f

The function for the Bearing Area curve produced by stats::ecdf().

a

Numeric. The left x boundary.

b

Numeric. The right x boundary.

n

Numeric. The number of subdivisions along the function line.

Details

The area under the curve used to calculate area above the curve is calculated as the numerical integral of the Bearing Area function from a to b using the trapezoid rule with n subdivisions. Assume a < b and n is a positive integer.

Value

A numeric value representing the area above the curve with x bounds a and b.

Examples

# import raster image
data(normforest)
normforest <- terra::unwrap(normforest)

# basic values
z <- terra::values(normforest)

# calculate cumulative probability density function of surface 'height' (= ndvi)
mod <- ecdf((1 - z))

# valley fluid retention index = void volume in 'valley' zone
Svi <- area_above(f = mod, b = 1, a = 0.8, n = 500)

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