calc_area: Area of a Cross Section

Description Usage Arguments Value Examples

View source: R/xs.r

Description

Compute cross section area from station-elevation data. This function is used internally by xs_area and should not be called by the user directly.

Usage

1
2
calc_area(dist, elev, left.bank = NA, right.bank = NA,
  reference.elev = NA, bottom.elev = NA)

Arguments

dist

The lateral cross section stations.

elev

The cross section elevations at each station.

left.bank

The left bank station. If NA, the minimum distance will be used.

right.bank

The right bank station. If NA, the minimum distance will be used.

reference.elev

The reference elevation to use for computing volume. Note that specifying a reference elevation lower than the maximum elevation of the cross section can introduce some error in the volume computation if the cross section data is not dense. If NA, the maximum elevation of the cross section will be used.

bottom.elev

Minimum elevation below which to ignore cross section volume; effectively flattens the cross section. Note that specifying a bottom elevation higher than the minimum elevation of the cross section can introduce some error in the volume computation if the cross section data is not dense. If NA, the minimum elevation of the cross section will be used.

Value

The flow area of the cross section. The maximum elevation is used as the upper boundary.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
test = data.frame(
  Distance = c(100, 120, 130, 150, 160, 180, 190, 210, 220, 240),
  Elevation = c(100, 100, 80, 80, 60, 60, 80, 80, 100, 100)
)
test.dens = data.frame(
  Distance = approx(test$Distance, test$Distance, xout = seq(100, 240))$y,
  Elevation = approx(test$Distance, test$Elevation, xout = seq(100, 240))$y
)
trap_area = function(a,b,h) 0.5*(a + b)*h
RAStestR:::calc_area(test$Distance, test$Elevation)
trap_area(100, 80, 20) + trap_area(40, 20, 20)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation)
trap_area(100, 80, 20) + trap_area(40, 20, 20)
RAStestR:::calc_area(test$Distance, test$Elevation,
  left.bank = 160, right.bank = 180)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation,
  left.bank = 160, right.bank = 180)
trap_area(20, 20, 40)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation, right.bank = 150)
trap_area(30, 20, 20)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation, left.bank = 210)
trap_area(10, 0, 20)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation, bottom.elev = 80)
trap_area(100, 80, 20)
RAStestR:::calc_area(test.dens$Distance, test.dens$Elevation, reference.elev = 80)
trap_area(40, 20, 20)

mkoohafkan/RAStestR documentation built on July 14, 2019, 11:41 p.m.