## default return with just one or several trees given is total coarse wood
## volume over bark, i.e. stock volume (in german: Vfm m.R.)
getVolume(list(spp = 1, D1 = 30, H = 25))
## first using a data.frame and height information
tree <- data.frame(spp = 1, D1 = 30, H = 25, A = 0.1, B = 10)
getVolume(tree) # iAB = "H", bark = TRUE, mapping = NULL as default values
getVolume(tree, iAB = "H", bark = FALSE, mapping = NULL)
## now, use diameter information
tree <- data.frame(spp = 1, D1 = 30, H = 25, A = 30, B = 7)
getVolume(tree, iAB = "Dob", bark = TRUE, mapping = NULL)
## now use both diameter and height information
tree <- data.frame(spp = 1, D1 = 30, H = 25, A = 0, B = 7)
getVolume(tree, iAB = c("H", "Dob"), bark = TRUE, mapping = NULL)
## is equivalent to the original BDAT-function:
BDATVOLDHMR(1, 30, 0, 0, 0, H = 25)
## and
getVolume(tree, iAB = c("H", "Dob"), bark = FALSE, mapping = NULL)
## is equivalent to:
BDATVOLDHOR(1, 30, 0, 0, 0, H = 25)
## use a misnamed data.frame and mapping argument
tree <- data.frame(BDATCode = 1, dbh = 30, h = 25, l = 30, u = 7)
getVolume(tree,
iAB = "Dob", bark = TRUE,
mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H", "l" = "A", "u" = "B")
)
## using a list to provide the data
tree <- list(
spp = c(1, 1), D1 = c(30, 25), H = c(25, 30), A = c(30, 25),
B = c(7, 7)
)
getVolume(tree, iAB = "Dob") #' defaults: bark = TRUE, mapping = NULL
getVolume(tree, iAB = "Dob", bark = FALSE) #' defaults: mapping = NULL
## using a misnamed list and mapping argument
tree <- list(
BDATCode = c(1, 1), dbh = c(30, 25), H = c(25, 30),
A = c(0.1, 0.1), B = c(1, 1)
)
getVolume(tree, mapping = c("BDATCode" = "spp", "dbh" = "D1"))
## using parameter AB to provide the segment data
## in this case a cross join between tree and AB is produced and evaluated
tree <- list(BDATCode = c(1, 1), dbh = c(30, 25), H = c(25, 30))
AB <- list(A = c(0.1, 1), B = c(1, 2))
getVolume(tree, AB, iAB = "H", bark = TRUE, mapping = c("BDATCode" = "spp", "dbh" = "D1"))
## effect of adjusting 'sl'
tree <- list(spp = 1, D1 = 30, H = 25)
getVolume(tree = tree, AB = list(A = 0.1, B = 5.1, sl = 2)) # default
getVolume(tree = tree, AB = list(A = 0.1, B = 5.1, sl = 1))
getVolume(tree = tree, AB = list(A = 0.1, B = 5.1, sl = 0.1))
getVolume(tree = tree, AB = list(A = 0.1, B = 5.1, sl = 0.01))
## compare Smalian formula to mid-diameter volume for sl=5
R1 <- getDiameter(tree, Hx = 1.3) / 100 / 2 # radius in m
R2 <- getDiameter(tree, Hx = 6.3) / 100 / 2 # radius in m
h <- 5
pi * ((R1 + R2) / 2)^2 * h # average of bottom and top diameter
(h * pi) / 3 * (R1^2 + R1 * R2 + R2^2) # truncated-cone volume
getVolume(tree, AB = list(A = 1.3, B = 6.3, sl = 5)) # mid-diameter volume
getVolume(tree, AB = list(A = 1.3, B = 6.3, sl = 0.01)) # physical volume
Run the code above in your browser using DataLab