# 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))
# calculate integral
int_area <- simpsons(f = mod, b = 1, a = 0.8, n = 500)
Run the code above in your browser using DataLab