library(aboveR)
library(terra)
#> terra 1.8.93
library(sf)
#> Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUEaboveR provides terrain analysis functions for LiDAR-derived elevation data: change detection between DEM epochs, cut/fill volume estimation, terrain profiling, erosion channel detection, reclamation monitoring, highwall classification, and flood risk assessment. The package also includes access utilities for Kentucky’s KyFromAbove cloud-native elevation data on AWS S3.
Load the bundled sample DEMs — a synthetic hillside before and after simulated mining activity:
before <- rast(system.file("extdata/dem_before.tif", package = "aboveR"))
after <- rast(system.file("extdata/dem_after.tif", package = "aboveR"))Compute terrain change:
The result has two layers: change (continuous
difference) and class (cut / stable / fill).
Estimate cut and fill volumes within a boundary polygon:
boundary <- st_read(
system.file("extdata/boundary.gpkg", package = "aboveR"),
quiet = TRUE
)
vol <- estimate_volume(after, before, boundary)
cat("Cut volume: ", round(vol$cut_volume_m3), "m3\n")
#> Cut volume: 224951 m3
cat("Fill volume:", round(vol$fill_volume_m3), "m3\n")
#> Fill volume: 2763 m3
cat("Net change: ", round(vol$net_volume_m3), "m3\n")
#> Net change: -222188 m3Extract elevation along a transect line:
line <- st_read(
system.file("extdata/profile_line.gpkg", package = "aboveR"),
quiet = TRUE
)
prof <- terrain_profile(before, line)
plot(prof$distance, prof$elevation, type = "l",
xlab = "Distance (m)", ylab = "Elevation (m)",
main = "Terrain Profile")Compute local surface roughness (standard deviation in a moving window):
The kfa_* functions provide access to Kentucky’s
statewide elevation data. These require internet connectivity: