calculateAngleMetrics: Calculate slope and bearing metrics

Description Usage Arguments Details Examples

View source: R/calculateSlopeBearing.R

Description

Functions for calculating slope and bearing metrics from NRSA protocol channel geometry data. The metrics calculated are: xbearing, sinu, xslope, vslope, nslope.

Usage

1
2
3
4
5
calculateAngleMetrics(uid, azimuth, distance)

calculateSlopeMetrics(uid, transect, slope, proportion)

calculateTransectSpacing(uid, transpc)

Arguments

uid

a vector of site identifiers

azimuth

a vector of bearings; more properly azimuths

distance

a vector of distances

transect

a vector of transect identifiers

transpc

a vector of transect spacing values

Details

The general strategy for calculationg slope and bearing metrics using these functions is:

  1. Calculate transect spacing for wadeable as: increment * nWadeableStationsPerTransect

  2. Calculate wadeable distance for each slope/bearing as transp * proportion

  3. Calculate boatable transect spacing as sum(distance) and proportion as distance / sum(distance)

  4. Calculate grade (as percent) from boatable elevation change measurements in centimeters, if applicable.

  5. Calculate angle metrics using calculateAngleMetrics

  6. Calculate slope metrics using calculateSlopeMetrics

The overall working of calculateAngleMetrics differs somewhat than the EPA code. EPA calculated total distances East and North at each transect, then summed to get the total distance East and North for the site. calculateAngleMetrics treats the channel geometry as a single line string and calculates the length of the line string and the distance from the first to last point. It calculates xbearing as the azimuth between the first and last points.

Function calculateTransectSpacing calculates the transect spacing. These should be the same for every transect. But for some sites, it's possible to get discrepancies between transects because of numerical issues. In that case the transect spacing won't be exactly the same at every transect. For that reason, we take the mean of the the transect spacing values for the site.

Examples

1
2
3
4
5
 d <- data.frame(uid = c(1,1), azimuth = c(180,90), distance = c(1,1))
 calculateAngleMetrics(d$uid, d$azimuth, d$distance)
 d <- data.frame(uid = rep(1,6), transect = rep(1:2,each = 3),
                 slope = rep(c(10, 20, 30), 2), proportion = rep(1,6) / 3)
 with(d, calculateSlopeMetrics(uid, transect, slope, proportion))

jasonelaw/nrsa documentation built on Nov. 8, 2019, 11:34 a.m.