| Type: | Package |
| Title: | Implementation of BDAT Tree Taper Fortran Functions |
| Version: | 1.1.0 |
| Description: | Implementing the BDAT tree taper Fortran routines, which were developed for the German National Forest Inventory (NFI), to calculate diameters, volume, assortments, double bark thickness and biomass for different tree species based on tree characteristics and sorting information. See Kublin (2003) <doi:10.1046/j.1439-0337.2003.00183.x> for details. |
| License: | BSD_2_clause + file LICENSE |
| URL: | https://gitlab.com/vochr/rbdat |
| Imports: | utils, graphics |
| Suggests: | knitr, pkgload, rmarkdown, RUnit, testthat |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | yes |
| Packaged: | 2025-06-06 14:25:54 UTC; christian.vonderach |
| Author: | Christian Vonderach [aut, cre], Edgar Kublin [aut], Bernhard Bösch [aut], Gerald Kändler [aut], Dominik Cullmann [ctb] |
| Maintainer: | Christian Vonderach <christian.vonderach@forst.bwl.de> |
| Repository: | CRAN |
| Date/Publication: | 2025-06-06 14:40:02 UTC |
Implementation of BDAT Tree Taper Fortran Functions
Description
Implementing the BDAT tree taper Fortran routines, which weredeveloped for the German National Forest Inventory (NFI), to calculatediameters, volume, assortments, double bark thickness and biomass fordifferent tree species based on tree characteristics and sorting information.
Author(s)
Maintainer: Christian Vonderachchristian.vonderach@forst.bwl.de
Authors:
Edgar Kublin
Bernhard Bösch
Gerald Kändler
Other contributors:
Dominik Cullmann [contributor]
References
Kublin E. (2003): Einheitliche Beschreibung der Schaftform –Methoden und Programme – BDATPro. Forstw. Cbl. 122, 183–200,https://link.springer.com/article/10.1046/j.1439-0337.2003.00183.x
Kublin E., Scharnagl. G. (1988): Verfahrens- undProgrammbeschreibung zum BWI-Unterprogramm BDAT: Abschlußbericht zumForschungsauftrag: "Biometrische Lösungen für die Berechnung des Volumens,der Sortierung, der Rindenabzüge und der Ernteverluste im Rahmen derBundeswaldinventur". ISSN: 0178-3165. Available athttps://gitlab.com/vochr/rbdat/-/blob/master/bdatdocs/
See Also
Useful links:
BDAT 2.0 assortment function
Description
Calculates volumes and assortments for given tree/s.
Usage
BDAT20( BDATArtNr, D1, H1 = 0, D2 = 0, H2 = 0, H, lX = 0, Hkz = 0, Skz = 0, Az = 0, Hsh = 0, Zsh = 0, Zab = 0, Sokz = 1, NMaxFixLng = 0, FixLngDef = matrix(rep(0, length(BDATArtNr) * 4), ncol = 4), result = "raw")Arguments
BDATArtNr | numeric, 1 <= spp <= 36, see |
D1 | numeric, first measured diameter [cm], usually in 1.3m |
H1 | numeric, height of first measured diameter [m] |
D2 | numeric, second measured diameter [cm], or form parameter,see |
H2 | H2: numeric, height of second measured diameter [m], or formparameter, see |
H | numeric, tree height [m] |
lX | length of unusable wood at stem foot [m], defaults to 0 |
Hkz | indicator for tree top, 0 - normal (default), 1 - Wipfelbruch,2 - Gipfelbruch |
Skz | indicator for stem type, defaults to 0, see |
Az | minimum cutting diameter over bark [cm], defaults to 0, usingtabulated data depending on DBH (not documented) |
Hsh | usable stem height, defaults to 0, i.e. 0.7*H |
Zsh | minimum cutting diameter under bark for stem wood [cm],defaults to 0, using tabulated data depending on DBH (not documented) |
Zab | minimum cutting diameter under bark for top segment [cm],defaults to 0, i.e. 14cm under bark. |
Sokz | type assortment calculation, 0 - no assortment,1 - mid diameter (Mittenstärke), 2 - Heilbronner Sortierung, defaults to 1 |
NMaxFixLng | number of fixed length assortments at stem foot, defaultsto 0 (no fixed length assortments, irrespective of |
FixLngDef | matrix of 4 * length(spp), having minimum cutting diameter,required assortment length, absolute and relative add-on |
result | indicator about what information should be returned |
Value
Using default value ofresult, which is 'raw', a list isreturned keeping information about the input value and produced assortments -the unprocessed returns from the Fortran code.
SeegetAssortment for more details, as this function isinternally called.
See Also
getAssortment for a more flexible function with amore convenient english name.
Examples
BDAT20(BDATArtNr = c(1, 1), D1 = c(30, 25), H = c(25, 20)) # returns long listBDAT20(BDATArtNr = c(1, 1), D1 = c(30, 25), H = c(25, 20), result = "Vol")# size classBDAT20(BDATArtNr = c(1, 1), D1 = c(30, 25), H = c(25, 20), result = "Skl")BDAT20( BDATArtNr = c(1, 1), D1 = c(30, 25), H = c(25, 20), NMaxFixLng = 1, result = "Fix")Get total aboveground biomasse
Description
BDAT-Function to get total aboveground biomass.
Usage
BDATBIOMASSE(BDATArtNr, D1, H1 = 0, D2 = 0, H2 = 0, H)Arguments
BDATArtNr | numeric vector of species code, see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
Details
This function returns total aboveground biomass for given tree/s,based on the biomass functions developed for the german NFI 3. See theadditional material for some german reference.
Value
vector of biomass for given trees
See Also
getBiomass for a function with more convenient englishname
Examples
## simple call of function, with all parameters givenBDATBIOMASSE(1, 30, 1.3, 0, 0, 25)## same with variablesBDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25BDATBIOMASSE(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H)## calling with a subset of tree characteristics## german species names, abbreviatedBDATBIOMASSE(getSpeciesCode(c("Fi", "Bu")), 30, H = 25)## english abbreviatedBDATBIOMASSE(getSpeciesCode(c("NS", "BE")), 30, H = 25)Calculate diameter in height Hx over bark.
Description
Function to call BDAT Fortran subroutine to calculate diameterover bark in height Hx for specified tree/s.
Usage
BDATDMRHX(BDATArtNr, D1, H1, D2, H2, H, Hx)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight. |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
Hx | height in tree for which diameter over bark is required |
Details
conventional function interface for Fortran function BDATDMRHX. SeegetDiameter for more details.
Value
vector of diameters over bark
See Also
BDATDORHX for BDAT routine calculating diameter underbark andgetDiameter for a function with a more convenientenglish name, more options and including a bark switch.
Examples
# simple call of function, with all parametersBDATDMRHX(1, 30, 1.3, 0, 0, 25, Hx = 1.3)# same with variablesBDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25Hx <- 1.3BDATDMRHX(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, Hx = Hx)## calling with a subset of tree characteristics## german species names, abbreviatedBDATDMRHX(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, Hx = 1.3)## english species names abbreviatedBDATDMRHX(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, Hx = 1.3)Calculate diameter in height Hx under bark.
Description
Function to call BDAT Fortran subroutine to calculate diameterunder bark in height Hx for specified tree/s.
Usage
BDATDORHX(BDATArtNr, D1, H1, D2, H2, H, Hx)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
Hx | height in tree for which diameter under bark is required |
Details
conventional function interface for BDATDORHX. SeegetDiameter for more details.
Value
vector of diameters under bark
See Also
BDATDMRHX for BDAT routine calculating diameter overbark,getDiameter for a function with a more convenient englishname, more options and a bark switch.
Examples
# simple call of function, with all parametersBDATDORHX(1, 30, 1.3, 0, 0, 25, Hx = 1.3)# same with variablesBDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25Hx <- 1.3BDATDORHX(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, Hx = Hx)## calling with a subset of tree characteristics## german species names, abbreviatedBDATDORHX(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, Hx = 1.3)## english species names abbreviatedBDATDORHX(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, Hx = 1.3)Calculate double bark thickness
Description
BDAT-Function to get double bark thickness at given height Hx
Usage
BDATRINDE2HX(BDATArtNr, D1, H1 = 1.3, D2 = 0, H2 = 0, H, Hx)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm] e.g. diameter in breast height |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
Hx | height for which double bark thickness is required [m] |
Details
This function returns double bark thickness in given heightHx in stemtaper (hence, it depends on the diameter in given height). This can be addedonto a diameter under bark to receive diameter over bark.
Value
vector of double bark thickness given heightHx inside stemtaper.
See Also
getBark for a function with a convenient english name
Examples
## simple call of function, with all parameters givenBDATRINDE2HX(1, 30, 1.3, 0, 0, 25, Hx = 1.3)## same with variablesBDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25Hx <- 1.3BDATRINDE2HX(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, Hx = Hx)## calling with a subset of tree characteristics## german species names, abbreviatedBDATRINDE2HX(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, Hx = 1.3)## english abbreviatedBDATRINDE2HX(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, Hx = 1.3)Calculate wood volume over bark of a tree between height A and B
Description
BDAT-Function to get wood volume over bark of one or many treesof a section between height A and height B
Usage
BDATVOLABMR(BDATArtNr, D1, H1 = 1.3, D2 = 0, H2 = 0, H, A, B, SekLng = 2)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight. |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
A | lower height of section for which volume is required [m] |
B | upper height of section for which volume is required [m] |
SekLng | length of section over which the integral of taper form shouldbe applied, defaults to 2.0m |
Details
wood volume is calculated using BDAT Fortran routines.
Value
vector of same length as input variables transformed into adata.frame, returning the required wood volume in cubic meter.
See Also
BDATVOLABOR for BDAT routine calculating volume underbark,getVolume for a function with a convenient english name,more options and a bark switch.
Examples
## simple call of function, with all parametersBDATVOLABMR(1, 30, 1.3, 0, 0, 25, .25, 5.25, 2.0)BDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25A <- 1B <- 10## same given variablesBDATVOLABMR(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, A = A, B = B)## calling with a subset of tree characteristics## german species names, abbreviatedBDATVOLABMR(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, A = 0, B = 25)## english abbreviatedBDATVOLABMR(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, A = 0, B = 25)Calculate volume under bark of a tree between height A and B
Description
BDAT-Function to get wood volume under bark of one or many treesof a section between height A and height B
Usage
BDATVOLABOR(BDATArtNr, D1, H1 = 1.3, D2 = 0, H2 = 0, H, A, B, SekLng = 2)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breast height |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
A | lower height of section for which volume is required [m] |
B | upper height of section for which volume is required [m] |
SekLng | length of section over which the integral of taper form shouldbe applied, defaults to 2.0m |
Details
wood volume is calculated using BDAT Fortran routines.
Value
vector of same length as input variables transformed into adata.frame, returning the required wood volume in cubic meter.
See Also
BDATVOLABMR for BDAT routine calculating volume overbark,getVolume for a function with a convenient english name,more options and including a bark switch.
Examples
## simple call of function, with all parametersBDATVOLABOR(1, 30, 1.3, 0, 0, 25, .25, 5.25, 2.0)BDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25A <- 1B <- 10## same with variablesBDATVOLABOR(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, A = A, B = B)## calling with a subset of tree characteristics## german species names, abbreviatedBDATVOLABOR(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, A = 0, B = 25)## english abbreviationBDATVOLABOR(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, A = 0, B = 25)Calculate (coarse) wood volume over bark of a tree up to given diameter
Description
BDAT-Function to get (coarse) wood volume over bark up to agiven diameter of one or many trees.
Usage
BDATVOLDHMR(BDATArtNr, D1, H1 = 1.3, D2 = 0, H2 = 0, H, DHGrz = 7, SekLng = 2)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight. |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
DHGrz | diameter over bark up to which volume should be calculated |
SekLng | length of section over which the integral of taper form shouldbe applied, defaults to 2.0m. |
Details
Volume is calculated using BDAT Fortran routines. In particular,BDATVOLDHMR internally callsBDATVOLABMR with parameterA = 0, i.e. volume is calculated from forest floor up to givendiameter, which itself is transformed into heightB.
Value
vector of same length as input variables transformed into adata.frame, returning the required volume in cubic meter.
See Also
BDATVOLDHOR for BDAT routine calculating volume underbark,getVolume for a function with a convenient english name,more options and including a bark switch.
Examples
## simple call of function, with all parameters givenBDATVOLDHMR(1, 30, 1.3, 0, 0, 25, 7, 2.0)BDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25DHGrz <- 7## same using variablesBDATVOLDHMR(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, DHGrz = DHGrz)## calling with a subset of tree characteristics## german species names, abbreviatedBDATVOLDHMR(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, DHGrz = 7)## english abbreviationBDATVOLDHMR(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, DHGrz = 7)Calculate (coarse) wood volume under bark of a tree up to given diameter
Description
BDAT-Function to get (coarse) wood volume under bark up to a givendiameter of one or many trees.
Usage
BDATVOLDHOR(BDATArtNr, D1, H1 = 1.3, D2 = 0, H2 = 0, H, DHGrz = 7, SekLng = 2)Arguments
BDATArtNr | numeric vector of species code; see |
D1 | first measured diameter of tree [cm], e.g. diameter in breastheight. |
H1 | measurement height of |
D2 | second measured diameter of tree, see |
H2 | measurement height of D2, see |
H | total tree height [m] |
DHGrz | diameter inside bark up to which volume should be calculated |
SekLng | length of section over which the integral of taper form shouldbe applied, defaults to 2.0m. |
Details
Volume is calculated using BDAT Fortran routines. In particular,BDATVOLDHOR internally callsBDATVOLABOR with parameterA = 0, i.e. volume is calculated from forest floor up to givendiameter, which itself is transformed into heightB.
Value
vector of same length as input variables transformed into a data.frame,returning the required volume in cubic meter.
See Also
BDATVOLDHMR for BDAT routine calculating volume overbark,getVolume for a function with a convenient english name,more options and including a bark switch.
Examples
## simple call of function, with all parametersBDATVOLDHOR(1, 30, 1.3, 0, 0, 25, 7, 2.0)## same using variablesBDATArtNr <- 1D1 <- 30H1 <- 1.3D2 <- 0H2 <- 0H <- 25DHGrz <- 7BDATVOLDHOR(BDATArtNr = BDATArtNr, D1 = D1, H1 = H1, D2 = D2, H2 = H2, H = H, DHGrz = DHGrz)## calling with a subset of tree characteristics## german species names, abbreviatedBDATVOLDHOR(getSpeciesCode(c("Fi", "Bu")), 30, 0, 0, 0, H = 25, DHGrz = 7)## english abbreviationBDATVOLDHOR(getSpeciesCode(c("NS", "BE")), 30, 0, 0, 0, H = 25, DHGrz = 7)Build and check tree data for subsequent use inBDAT Fortran subroutines
Description
this functions takes the data provided and builds a data.frameto be used in other BDAT get*-functions. It discriminates between differenttype of required output via thecheck-parameter. Checks are done onthe type and range of the variables given to make sure calls to theFortran routines do not suffer from type-mismatch (with potential freezingof R).
Usage
buildTree(tree, check = NULL, vars = NULL, mapping = NULL)Arguments
tree | either a data.frame or a list containing the variables needed,i.e. spp, D1, H and optionally H1, D2, H2. See details for moreinformation and parameter |
check | character vector which indicates the type of required output anddetermines the checks to be done |
vars | named list with additional variables for the specificBDAT-functions; see |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
Parametertree is able to take either a data.frame withcorrect variables names or arbitrary names ifmapping is provided tomap the data.frame names to the required names byc("df-colname" = "var-name") or to take a named list. If same-namedvariables are present in bothtree andvars, priority is puton the ones invars since explicitly given.
Possible variables are (*=required, depending on function):
spp*: numeric, 1 <= spp <= 36, see
getSpeciesCodeD1*: numeric, first measured diameter [cm], usually at 1.3m
H1: numeric, height of first measured diameter [m], if zero,internally transformed to 1.3m
D2: numeric, second measured diameter [cm], or form parameter: latteris defined in conjunction with
H2:D2=0 and H2=0 => taper form of volume tables according toGrundner & Schwappach (1906-1938), the default
D2=0 and 0 < H2 < 100 => german NFI1-taper form, with H2 given aspercentile of the NFI1-
q_{0.30}-distribution; H2=50corresponds to mean NFI1 taper form, H2<50 to slenderly and H2>50 tothicker trees; seegetFormfor more information aboutq_{0.30}D2=0 and H2>100 => mean NFI1 taper form
D2>0 and H2=0 => D2 is a diameter and H2 is assumed to be 7m
D2>0 and H2>0 => D2 and H2 are given as diameter and height
-1<D2<0 => abs(D2) is interpreted as
q_{0.30}-1>D2 => mean NFI1 taper form
H2: numeric, height of second measured diameter [m], or inconjunction with
D2, see there.H*: numeric, tree height [m]
A*: numeric, lower diameter [cm] or height [m] of section for whichvolume should be calculated, interpretation depends on
iAB, seegetVolumeB*: numeric, upper diameter [cm] or height [m] of section for whichvolume should be calculated, interpretation depends on
iAB, seegetVolumesl: numeric, length of section over which should be integrated,defaults to 2.0m
Dx*: diameter for which height or bark thickness is required
Hx*: height for which diameter is required
inv: inventory for which mean q03 is required, defaults to 1, see
getForm
For deriving assortments, the following variables are optional (if not given,default values are used):
lX: length of unusable wood at stem foot [m], defaults to 0 (X-Holz)
Hkz: indicator for tree top, 0 - normal (default), 1 - Wipfelbruch, 2 - Gipfelbruch
0 => H=H
1 => H=H+2
2 => DBH < 30 => H=DBH; dbh > 30 => H = 30 + (DBH-30) * 0.3
Skz: indicator for stem type, defaults to 0
0 => conifer trees => no restriction; deciduous trees => no assortments
1 => monopodial deciduous trees => Hsh = 0.7*H
2 => branching between dbh and 7m => Hsh = 5m
3 => crown base < 3m => Hsh=0.1
4 => dead or broken stem => Az = H*0.7
5 => dead tree => non-usable wood
Hsh: usable stem height, defaults to 0, i.e. 0.7*H
Az: minimum cutting diameter over bark [cm], defaults to 0,using an exponential function given DBH
Zsh: minimum cutting diameter under bark for stem wood [cm], defaultsto 0, using parameter
Azif estimated length < maximum length (i.e. 20m)Zab: minimum cutting diameter under bark for top segment [cm], defaultsto 0, i.e. 14cm under bark
Sokz: type assortment calculation, 0 - no assortment,1 - Mid diameter (Mittenstärke), 2 - Heilbronner Sortierung, defaults to 1
fixN: number of fixed length assortments at stem foot, defaults to 0(no fixed length assortments, irrespective of other fix* parameters)
fixZ: mininum diameter under bark for fixed length assortment atstem foot, defaults to 0
fixL: length of fixed length assortment at stem foot, defaults to 0
fixA: fixed length assortement add-on in [cm], defaults to 0
fixR: fixed length assortement add-on in [%], defaults to 0
If parametertree is used to hand over all tree data in form ofa data.frame, at least the parameter spp, D1, H must be provided, eventuallymapped viamapping.ParameterHx andDx, which specify height and diameter forwhich a diameter or height is requested, respectively, can either be includedto the definition of the tree data or alternatively given separately usingthe vars parameter. In that case, vars is used in priority to a identicallynamed variable intree. Additionally,tree andvars aremerged via a full outer join.The add-on in fixed length assortments can be given in absolute and relativeunits at the same time, but the higher value will be used.
Value
a data.frame of class datBDAT.<check> having all variables needed inspecific functions. Ifcheck is NULL, only a basic tree-data.frame ofclass "datBDAT" is returned.
Examples
## example for only tree datatree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))res <- buildTree(tree = tree)head(res)class(res)tree <- list(species = c(1, 1), dbh = c(30, 25), h = c(25, 30))mapping <- c("species" = "spp", "dbh" = "D1", "h" = "H")res <- buildTree(tree = tree, mapping = mapping)head(res)class(res)## example for diameter calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))vars <- list(Hx = c(1.3, 1.3))mapping <- NULLres <- buildTree(tree = tree, check = "diameter", vars = vars)head(res)class(res)tree <- list(Art = c(1, 1), Bhd = c(30, 25), H = c(25, 30))vars <- list(X = c(1.3, 1.3))mapping <- c("Art" = "spp", "Bhd" = "D1", "X" = "Hx")res <- buildTree(tree = tree, check = "diameter", vars = vars, mapping = mapping)head(res)class(res)## example with many diameters for one treetree <- list(spp = c(1), D1 = c(30), H = c(25))vars <- list(Hx = seq(0, 25, 0.1))mapping <- NULLres <- buildTree(tree = tree, check = "diameter", vars = vars)tree <- data.frame(s = 1, d = 30, h = 25, hx = 1.3)mapping <- c("s" = "spp", "d" = "D1", "h" = "H", "hx" = "Hx")res <- buildTree(tree, check = "diameter", mapping = mapping)head(res)class(res)## example for height calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))vars <- list(Dx = c(30, 25))res <- buildTree(tree = tree, check = "height", vars = vars)head(res)class(res)## example for volume calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))check <- "volume"vars <- list(A = c(30, 25), B = c(7, 7), sl = 0.1)mapping <- NULLres <- buildTree(tree = tree, check = "volume", vars = vars)head(res)class(res)## example for bark calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))vars <- list(Hx = c(1.3, 1.3))res <- buildTree(tree = tree, check = "bark", vars = vars)head(res)class(res)## example for assortment calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))vars <- list(fixN = 1, fixZ = 10, fixL = 5, fixA = 10, fixR = 0.1)res <- buildTree(tree = tree, check = "assortment", vars = vars)head(res)class(res)## for cases where 'vars' could be a vector (i.e. getBark, getDiameter and## getHeight), the following is also possibletree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))vars <- c(1.3, 1.3)res <- buildTree(tree = tree, check = "bark", vars = vars)head(res)class(res)res <- buildTree(tree = tree, check = "height", vars = vars)head(res)class(res)## but it is not possible in case of getVolume or getAssortment## instead, use a named list to achieve a cross join / cartesian productvars <- list(A = rep(1, 3), B = 5:7)res <- buildTree(tree = tree, check = "volume", vars = vars)head(res)class(res)## example for 'biomass' calculationtree <- list(spp = c(1, 1), D1 = c(30, 25), H = c(25, 30))res <- buildTree(tree = tree, check = "biomass")head(res)class(res)## example with H1 != 1.3mtree <- list( spp = c(1, 1), D1 = c(30, 25), H1 = c(2, 2), H = c(25, 30))res <- buildTree(tree = tree, check = "biomass")head(res)class(res)getBiomass(res)clear errors from subroutine BDAT20
Description
Returns the NA'd data set
Usage
clearError(data)Arguments
data | result of subroutine BDAT20 |
Value
a corrected, i.e. NA'd version of the input
Return dedicated error message
Description
Returns the correct error message of SUBROUTINE BDAT20 according to helpfile of BDAT
Usage
errormessage(code)Arguments
code | error codes from subroutine BDAT20 (parameter 'Ifeh') |
Value
returns the error message of the respective codes
Get assortments for one or many trees
Description
Function to get assortments given harvest specifications for atree of dimension D1, possible D2, and H. Assortments could be diameteror length constrained.
Usage
getAssortment(tree, ...)## S3 method for class 'data.frame'getAssortment(tree, sort = NULL, mapping = NULL, value = "merge", ...)## S3 method for class 'list'getAssortment(tree, sort = NULL, mapping = NULL, value = "merge", ...)## S3 method for class 'datBDAT'getAssortment(tree, sort = NULL, mapping = NULL, value = "merge", ...)Arguments
tree | either an object of class 'datBDAT.assortment' or a data.frame orlist containing the variables needed, i.e. spp, D1, H, and optionallyH1, D2, H2 for specifying the tree. See |
... | passing arguments to methods. |
sort | named list with variables specifying assortments, see |
mapping | mapping of variable names in case a data.frame is given intoparameter |
value | character vector indicating return type: either "Vol", "Skl","Fix", "LDSort", "merge" (default) or "raw". See section Value. |
Details
Parameter 'tree' is able to take either a data.frame with correctvariables names or arbitrary names ifmapping is provided to map thedata.frame names to the required names byc("df-colname" = "var-name")or to take a named list.
Assortments are calculated using BDAT2.0 Fortran routines. Slightly extended,it now is possible to return length and diameter information also aboutstandard assortments (which are held in "Vol"-element of return list,if value="raw" or value="Vol").
The standard assortment names are:
X = non-usable wood at stem foot (X-Holz)
Sth = stem wood
Ab = upper part of stem wood, second length after transport cut
Ind = industrial wood
nvDh = non-usable coarse wood
Value
depending onvalue either information about 'Skl,' 'Vol' or'Fix' (these are elements of standard output of Fortran BDAT20 subroutine)and, additionally, information about the 'Vol' elements is retrieved byvalue="LDSort" orifvalue = 'merge' than a combined information of all producedassortments with name, base position, assortment length, mid-diameter,top-diameter and volume is produced. This is most likely what you want,hence the default. Standard output of BDAT is provided byvalue="raw".Since v0.4.0 a vectorized BDAT-fortran-function is implemented, so eachelement of the returned list in case of value="raw" keeps information of alltrees given. Make sure to appropriately split and manipulate this data.
Methods (by class)
getAssortment(data.frame): transformingdata.framebefore callinggetAssortmentusingbuildTreegetAssortment(list): transforminglistbefore callinggetAssortmentusingbuildTreegetAssortment(datBDAT): class method for classdatBDAT
See Also
BDATVOLABMR andBDATVOLABOR for aBDAT-type wrapper and function to keep back-compatability. To get coarse woodvolume over bark (>=7m diameter over bark) BDAT-type functions areBDATVOLDHMR andBDATVOLDHOR.
Examples
tree <- data.frame(spp = 1, D1 = 30, H = 25)sort <- list(Az = 7, Sokz = 1)getAssortment(tree, sort, value = "Vol")getAssortment(tree, sort, value = "Skl")sort <- list(Az = 7, Sokz = 1, fixN = 1, fixZ = 10, fixL = 5, fixA = 10, fixR = 1)getAssortment(tree, sort, value = "Vol")getAssortment(tree, sort, value = "Skl")getAssortment(tree, sort, value = "Fix")getAssortment(tree, sort, value = "LDSort")getAssortment(tree, sort, value = "merge")## prepare data for repeated sorting## (get rid of preparating data handling)n <- 3tree <- data.frame( spp = rep(1, n), D1 = seq(20, 50, length.out = n), H = seq(15, 40, length.out = n))sort <- list(lX = 0, Sokz = 1, Az = 7, fixN = 2, fixZ = 10, fixL = 5, fixA = 10, fixR = 1)tree <- buildTree(tree = tree, check = "assortment", vars = sort)getAssortment(tree, value = "Vol")getAssortment(tree, value = "Skl")getAssortment(tree, value = "Fix")getAssortment(tree, value = "LDSort")getAssortment(tree, value = "merge")## to get bare BDAT-Output, use value='raw'# very long list, each element keeping all treesgetAssortment(tree, value="raw")# bonus: it returns the calling parameters as wellGet double bark thickness of tree at given height Hx
Description
this function calculates double bark thickness in given heightfor a given tree
Usage
getBark(tree, ...)## S3 method for class 'data.frame'getBark(tree, Hx = NULL, mapping = NULL, ...)## S3 method for class 'list'getBark(tree, Hx = NULL, mapping = NULL, ...)## S3 method for class 'datBDAT'getBark(tree, Hx = NULL, mapping = NULL, ...)Arguments
tree | either a data.frame or a list containing the variables needed todecribe a tree, i.e. spp, D1, H, and optionally H1, D2, H2. Additionally,parameter |
... | passing arguments to methods. |
Hx | height in tree for which double bark thickness is required |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
This function returns double bark thickness in given heightHx in stemtaper (hence, it depends on the diameter in given height). This can be addedto an diameter under bark to get the diameter over bark.Parametertree is able to take either a data.frame with correctvariables names or arbitrary names ifmapping is provided to map thedata.frame names to the required names byc("df-colname" = "var-name")or to take a named list.
Value
vector of double bark thickness given heightHx inside stem taper
Methods (by class)
getBark(data.frame): transformingdata.framebefore callinggetBarkusingbuildTreegetBark(list): transforminglistbefore callinggetBarkusingbuildTreegetBark(datBDAT): class method for classdatBDAT
Examples
tree <- data.frame(spp = c(1, 1), D1 = c(30, 25), H = c(25, 25), Hx = c(1.3, 22.248))getBark(tree)tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 25), Hx = c(1.3, 22.248))getBark(tree, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 25))Hx <- list(Hx = c(1.3, 22.248))getBark(tree = tree, Hx = Hx, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))Get total aboveground biomass of tree
Description
this function calculates total aboveground biomassfor a given tree
Usage
getBiomass(tree, ...)## S3 method for class 'data.frame'getBiomass(tree, mapping = NULL, ...)## S3 method for class 'list'getBiomass(tree, mapping = NULL, ...)## S3 method for class 'datBDAT'getBiomass(tree, mapping = NULL, ...)Arguments
tree | either a data.frame or a list containing the variables needed todecribe a tree, i.e. spp, D1, H, and optionally H1, D2, H2. See |
... | passing arguments to methods. |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
This function returns total aboveground biomass according to the biomassfunctions developed for the german NFI3 (BWI3) on the basis of a field surveycovering whole Germany from 2007 to 2010. Hence, the base data differs fromthose used to fit the taper functions. Neverteless and although the originalfortran code does not provide an interface to pass H2 or negative D2 valuesto the functions (they were fitted with abolute D03-values, i.e. diameterin 30for reasons of consistency.
The functions themselves are fitted for four species (Norway spruce, Scotspine, European beech and Oak spp.) directly, and for another fourteen speciesby generating pseudo-observations and fitting the functions to these. Seethe enclosed report for details.
The biomass functions integrate four different ranges of validity: (i) treeheight below 1.3m, (ii) dbh below 10cm, (iii) dbh between 10cm and the99th-quantile of the data and (iv) dbh above.
Value
vector of total aboveground biomass
Methods (by class)
getBiomass(data.frame): transformingdata.framebefore callinggetBiomassusingbuildTreegetBiomass(list): transforminglistbefore callinggetBiomassusingbuildTreegetBiomass(datBDAT): class method for classdatBDAT
References
Riedel, T. and G. Kaendler (2017). "NationaleTreibhausgasberichterstattung: Neue Funktionen zur Schätzung deroberirdischen Biomasse am Einzelbaum." Forstarchiv 88(2): 31-38.
Examples
tree <- data.frame(spp = c(1, 1), D1 = c(30, 25), H = c(25, 25))getBiomass(tree)tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 25))getBiomass(tree, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 25))getBiomass(tree = tree, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))## this is standard usage of the fortran code## now changing the taper form via second diameter D2tree <- data.frame(spp = 1, D1 = 30, D2 = c(26, 24), H = 25)getBiomass(tree)## the following usage of D2 and H2 w.r.t. the biomass functions are new## and unique to R## now changing the taper form via quantile of second diameter in H2tree <- data.frame(spp = 1, D1 = 30, H2 = c(25, 50, 75), H = 25)getBiomass(tree)## now changing the taper form via form quotient (i.e. negative D2)fq <- getForm(list(spp = 1, D1 = 30, H = 25), inv = 1:4)tree <- data.frame(spp = 1, D1 = 30, D2 = -fq, H = 25)getBiomass(tree) # biomass of an average tree according to different inventoriesGet diameter in given height inside tree taper
Description
this function calculates the diameter inside or outside bark ofin given height for a given tree
Usage
getDiameter(tree, ...)## S3 method for class 'data.frame'getDiameter(tree, Hx = NULL, bark = TRUE, mapping = NULL, ...)## S3 method for class 'list'getDiameter(tree, Hx = NULL, bark = TRUE, mapping = NULL, ...)## S3 method for class 'datBDAT'getDiameter(tree, Hx = NULL, bark = TRUE, mapping = NULL, ...)Arguments
tree | either a data.frame, a list or an object of class |
... | passing arguments to methods. |
Hx | height in tree for which diameter over or under bark is required;defaults to NULL |
bark | logical, if TRUE returned diameter |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
if tree does not includes variable Hx, a full outer join isgenerated between both
Value
a matrix with one row for each tree and one column for eachHxgiven, holding the diameter over or under bark of provided heightHxinside stem taper. The matrix is simplified by[,,drop=TRUE],especially ifHx=NULL.
Methods (by class)
getDiameter(data.frame): transformingdata.framebefore callinggetDiameterusingbuildTreegetDiameter(list): transforminglistbefore callinggetDiameterusingbuildTreegetDiameter(datBDAT): class method for classdatBDAT
Examples
tree <- data.frame(spp = c(1, 1), D1 = c(30, 30), H = c(25, 25), Hx = c(1.3, 22.248))getDiameter(tree, bark = TRUE)getDiameter(tree, bark = FALSE)tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 30), h = c(25, 25), Hx = c(1.3, 22.248))getDiameter(tree, bark = TRUE, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 30), h = c(25, 25))Hx <- c(1.3, 22.248)getDiameter(tree, Hx = Hx, bark = TRUE, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))Get estimated mean of form factor q03
Description
this function returns for a given dbh-height-class and speciesthe estimated mean of the q03-distribution, which can be considered as aform factor for different inventories (i.e. NFI 1, NSoG, IS08, NFI3).
Usage
getForm(tree, ...)## S3 method for class 'data.frame'getForm(tree, inv = NULL, mapping = NULL, ...)## S3 method for class 'list'getForm(tree, inv = NULL, mapping = NULL, ...)## S3 method for class 'datBDAT'getForm(tree, inv = NULL, mapping = NULL, ...)Arguments
tree | either a data.frame or a list containing the variables needed todecribe a tree, i.e. spp, D1, H, and optionally H1, D2, H2. See |
... | passing arguments to methods. |
inv | integer, indicator for which inventory the form factor should bereturned; defaults to 1 (0=volume tables of Grundner-Schwappach 1921,1=NFI1, 2=NSoG, 3=IS08, 4=NFI3).Any other value is silently set back to |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
This function returns the estimated mean of the q03-distribution for a givendbh-height-class and species. The q03-distribution is the ratio between thediameter in 30% of tree height and 5% of tree height and describes the formof the taper curve. This value can be returned for different inventories,during which upper stem diameters have been sampled.
Only spp, D1 and H are used to estimate mean q03, if provided and H1 equals1.3m, otherwise dbh is estimated using BDAT functions (i.e.getDiameter(tree, Hx=1.3)).
Value
vector of form factor q03.
Methods (by class)
getForm(data.frame): transformingdata.framebefore callinggetFormusingbuildTreegetForm(list): transforminglistbefore callinggetFormusingbuildTreegetForm(datBDAT): class method for classdatBDAT
Examples
tree <- data.frame(spp = c(1, 1), D1 = c(30, 25), H = c(25, 25))tree <- buildTree(tree, check = "form", vars = list(inv = 1))str(tree)getForm(tree) # default is 'inv=1'getForm(tree, inv = 0) # taper form of BDAT from model fitgetForm(tree, inv = 1) # NFI 1 (without NSoG)getForm(tree, inv = 2) # NSoG = New States of GermanygetForm(tree, inv = 3) # carbon inventory 2008getForm(tree, inv = 4) # NFI 3 (reunificated Germany)Get height of given diameter inside tree taper
Description
this function calculates the height of a given diameter insideor outside bark for a given tree
Usage
getHeight(tree, ...)## S3 method for class 'data.frame'getHeight(tree, Dx = NULL, bark = TRUE, mapping = NULL, ...)## S3 method for class 'list'getHeight(tree, Dx = NULL, bark = TRUE, mapping = NULL, ...)## S3 method for class 'datBDAT'getHeight(tree, Dx = NULL, bark = TRUE, mapping = NULL, ...)Arguments
tree | either a data.frame or a list containing the variables needed todecribe a tree, i.e. spp, D1, H, and optionally H1, D2, H2. See |
... | passing arguments to methods. |
Dx | diameter of tree for which height is required; defaults to NULL |
bark | logical, if TRUE given diameter |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
seebuildTree for how to specify a tree object
Value
a matrix with one row for each tree and one column for eachDxgiven, holding the height of provided diameterDx inside stem taper.The matrix is simplified by[,,drop=TRUE], especially ifDx=NULL.
Methods (by class)
getHeight(data.frame): transformingdata.framebefore callinggetHeightusingbuildTreegetHeight(list): transforminglistbefore callinggetHeightusingbuildTreegetHeight(datBDAT): class method for classdatBDAT
Examples
tree <- data.frame(spp = c(1, 1), D1 = c(30, 25), H = c(25, 20), Dx = c(7, 7))getHeight(tree, bark = TRUE)getHeight(tree, bark = FALSE)tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 20), Dx = c(7, 7))getHeight(tree, bark = TRUE, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))tree <- data.frame(BDATCode = c(1, 1), dbh = c(30, 25), h = c(25, 20))Dx <- c(7, 5)getHeight(tree, Dx = Dx, bark = TRUE, mapping = c("BDATCode" = "spp", "dbh" = "D1", "h" = "H"))tree <- data.frame(spp = c(1, 1), D1 = c(30, 25), H = c(25, 20), Dx = c(7, 7))getHeight(tree, Dx = c(1:5), bark = TRUE)Get BDAT species code or transform it to a name.
Description
Function to get BDAT species code, or transform it to agerman or english name, possibly an abbreviated version or even a scientificname
Usage
getSpeciesCode(inSp = NULL, outSp = NULL, version = c(2, 1))Arguments
inSp | species information given, either numeric or character |
outSp | character vector of names, for which information should be returned |
version | numeric vector giving which look-up table version is required.Defaults to |
Details
The function matches inSp to outSp. Depending on inSp, being eithera numeric vector of values between 1 and 36 or a character vector of speciesnames. Possible names are those which could be return values. One can get allnames and the respective species code by calling the function withinSP=NULL andoutSP=NULL (the default).
English species names and codes are now (June 2025) taken from the GermanNational Forest Inventory (version=2, default), in the previousversion (version=1) the English species names were taken fromhttps://www.forestry.gov.uk/pdf/PF2011_Tree_Species.pdf/$FILE/PF2011_Tree_Species.pdfwhile slightly adjusting the codes to be unique compared to the german codes(e.g. European larch is now ELA instead of EL).
The version change only refers to columnlong, not to columnshort.
Any given species code outside the interval [1, 36] is set back to the code 1(i.e. European spruce (version=2) or Norway spruce (version=1)), whilethrowing a warning. If any inSp - name is invalid, i.e. not in species list,this throws an error.
All elements of outSp, which are not column names of the default returneddata.frame, are silently dropped.
Value
vector or data.frame, depending on length of 'outSp'.
Examples
getSpeciesCode(inSp = NULL, outSp = NULL) ## the defaultgetSpeciesCode() ## the samegetSpeciesCode(outSp = "scientific")getSpeciesCode(inSp = c(1, 2)) ## giving codesgetSpeciesCode(inSp = c(1, 2, -1, 37)) ## values outside [1, 36] are given code 1getSpeciesCode(inSp = c(1, 2), outSp = c("scientific")) ## output a vectorgetSpeciesCode(inSp = c("Bu", "Fi")) ## asking for codes of abbreviated german namesgetSpeciesCode(inSp = c("Bu", "Fi", "Bu")) ## order is preservedgetSpeciesCode(inSp = c("Buche", "Fichte")) ## asking for codes of german namesgetSpeciesCode(inSp = c("BE", "NS")) ## ... abbreviated english namesgetSpeciesCode(inSp = c("Common beech", "European spruce")) ## ... english namesgetSpeciesCode(inSp = c("Fagus sylvatica", "Picea abies")) ### ... scientific names# get previous species look-up tablegetSpeciesCode(version=1)# as compared to the current versiongetSpeciesCode() # or explicitlygetSpeciesCode(version=2)Get segment volume for one or many trees
Description
Function to get segment volume over or under bark for a tree ofdimension D1, possible D2, and H. Volume is calculated for a given segmentdefined by A and B, which might be specified as heights or diameters.
Usage
getVolume(tree, ...)## S3 method for class 'data.frame'getVolume(tree, AB = NULL, iAB = "H", bark = TRUE, mapping = NULL, ...)## S3 method for class 'list'getVolume(tree, AB = NULL, iAB = "H", bark = TRUE, mapping = NULL, ...)## S3 method for class 'datBDAT'getVolume(tree, AB = NULL, iAB = "H", bark = TRUE, mapping = NULL, ...)Arguments
tree | either a data.frame or a list containing the variables needed todecribe a tree, i.e. spp, D1, H, and optionally H1, D2, H2. See |
... | passing arguments to methods. |
AB | list with heights or diameters A and B of section for which volumeover or under bark should be calculated. Additionally, add in |
iAB | character indicating how to interpret given A and B values. Either"H" (the default), "Dob" (diameter over bark) or "Dub" (diameter under bark).Could be of length one or two, depending on whether A and B are both heightor diameter variables or not. See examples. |
bark | boolean of length one indicator for whether required volume shouldinclude bark volume or not. Defaults to TRUE. Coerced to logical by |
mapping | mapping of variable names in case a data.frame is given intoparameter |
Details
iAB can be a vector of length two, indicating how to interpretA andB. Hence, one can calculate volume between a givenheight and a given diameter, either over or under bark. If of length one,it is assumed the indicator applies to both A and B.
Internally, provided diameters inA orB are tranformed toheights byBDATHXDX if iAB="dob" or byBDATHXDXOR ifiAB="dub".
Value
vector of same length as tree, returning the required volume incubic meter.
Methods (by class)
getVolume(data.frame): transformingdata.framebefore callinggetVolumeusingbuildTreegetVolume(list): transformingdata.framebefore callinggetVolumeusingbuildTreegetVolume(datBDAT): class method for classdatBDAT
See Also
BDATVOLABMR andBDATVOLABOR for aBDAT-type wrapper and function to keep back-compatability. To get totalcoarse wood volume (>=7m diameter over bark) BDAT-type functions areBDATVOLDHMR andBDATVOLDHOR.
Examples
## 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 informationtree <- data.frame(spp = 1, D1 = 30, H = 25, A = 0.1, B = 10)getVolume(tree) # iAB = "H", bark = TRUE, mapping = NULL as default valuesgetVolume(tree, iAB = "H", bark = FALSE, mapping = NULL)## now, use diameter informationtree <- 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 informationtree <- 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)## andgetVolume(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 argumenttree <- 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 datatree <- 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 = NULLgetVolume(tree, iAB = "Dob", bark = FALSE) #' defaults: mapping = NULL## using a misnamed list and mapping argumenttree <- 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 evaluatedtree <- 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)) # defaultgetVolume(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=5R1 <- getDiameter(tree, Hx = 1.3) / 100 / 2 # radius in mR2 <- getDiameter(tree, Hx = 6.3) / 100 / 2 # radius in mh <- 5pi * ((R1 + R2) / 2)^2 * h # average of bottom and top diameter(h * pi) / 3 * (R1^2 + R1 * R2 + R2^2) # truncated-cone volumegetVolume(tree, AB = list(A = 1.3, B = 6.3, sl = 5)) # mid-diameter volumegetVolume(tree, AB = list(A = 1.3, B = 6.3, sl = 0.01)) # physical volumePlot taper curve of a tree
Description
creating a plot of the taper curve of a tree, over or under bark
Usage
## S3 method for class 'datBDAT'plot(x, bark = NULL, col.bark = NULL, legend = FALSE, assort = NULL, ...)Arguments
x | an object of class 'datBDAT' |
bark | either NULL or logical; if TRUE taper curve over bark is plotted,if FALSE taper curve under bark is plotted; if NULL, both are plotted |
col.bark | color to be used for plot of bark, if plot of taper curveover and under bark is requested |
legend | logical, if legend should be added |
assort | assortments produced by |
... | further arguments for |
Details
Creates graphics of the taper curve of trees. Either over bark orunder bark, or both. Elements design can partly be chosen. If assortments aregiven, these are added to the plot. Doing that, the assortment bottom and topposition is indicated by a vertical line and mid-diameter is shown as a pointwith vertical dashed line. N.B. the mid-diameter shown is under bark androunded downwards for 0.5 cm if mid-diameter < 20 and for 0.75 cm if bigger.Assortment volume is calculated using this diameter according to the legalrules for roundwood assortments (formerly german Forst-HKS and now RVR).Additionally, assortment names are indicated.One can provide assortment names in a column ofassort named'assortname', which will be used if available, otherwise the 'Sort'-columnwill be used. See Examples.
Value
No return value, called for side effects
Examples
## plotting the taper curve of a treeoldpar <- par(no.readonly = TRUE)par(mfrow = c(1, 1))t <- data.frame(spp = 1, D1 = 40, H = 35)tree <- buildTree(tree = t)plot(tree, type = "l", las = 1, legend = TRUE)plot(tree, bark = TRUE, las = 1)plot(tree, bark = FALSE, las = 1)t <- data.frame(spp = c(1, 1), D1 = c(40, 35), H = c(35, 30))tree <- buildTree(tree = t)plot(tree, bark = FALSE, las = 1, legend = TRUE)plot(tree, bark = TRUE, las = 1, legend = TRUE)t <- data.frame(spp = c(1, 8), D1 = 40, H = 35)tree <- buildTree(tree = t)plot(tree, bark = NULL, las = 1, col.bark = "blue", legend = TRUE)plot(tree[1, ], main = getSpeciesCode(tree[1, ]$spp, out = "long"))plot(tree[2, ], main = getSpeciesCode(tree[2, ]$spp, out = "scientific"))par(mfrow = c(2, 1))plot(tree, bark = TRUE, las = 1)## now add assortments into taper curvepar(mfrow = c(1, 1))ass <- getAssortment(tree, sort = list(lX = 1, fixN = 2, fixL = 4, fixA = 10))plot(tree, assort = ass)plot(tree, bark = FALSE, assort = ass)plot(tree, bark = FALSE, assort = ass, legend = TRUE)plot(tree[1, ], assort = ass[ass$tree == 1, ], main = "first tree in subset")plot(tree[2, ], assort = ass[ass$tree == 2, ], main = "second tree in subset")## adding own assortment labels using column 'assortname'ass$assortname <- ifelse(grepl("Fix", ass$Sort), paste0("Fix:", ass$length), ass$Sort)plot(tree, assort = ass)par(oldpar)Throw a Condition
Description
Throws a condition of class c("error", "rBDAT", "condition").
Usage
throw(message_string, system_call = sys.call(-1), ...)Arguments
message_string | The message to be thrown. |
system_call | The call to be thrown. |
... | Arguments to be passed to |
Details
We use this condition as an error dedicated to rBDAT.
Value
The function does never return anything, it stops with acondition of class c("error", "rBDAT", "condition").
transform BDAT20-matrix
Description
transforms an intermediate BDAT20-matrix into a data.frame,names it appropriately and removes <zero>-entries.
Usage
transformBDAT20(assort, value)Arguments
assort | a matrix, produced by calling Fortran-BDAT20-subroutine andextracting one list element to a matrix |
value | character vector indicating return type: either "Vol", "Skl"or "Fix" |
Details
Fortran subroutine BDAT20 returns a list with many entries for eachtree; most relevant are 'Vol', 'FixLng' and maybe 'Skl'. These elements aretransformed into a matrix and properly whiped into shape.
Value
a transformed BDAT20-result, usually a data.frame
replace NAMESPACE from 'rBDATPRO' to 'rBDAT'.
Description
function replaces calls to package 'rBDATPRO' by calls topackage 'rBDAT', simply by replacing the package name.
Usage
updateBdatNamespace(inpath = file.choose(), outpath = NULL)Arguments
inpath | path of file to process |
outpath | either a file name or a directory, both or NULL, see details. |
Details
This function merely exists to account for the renaming of thepackage fromrBDATPRO (which was internally used for some period oftime) torBDAT. Its sole purpose is to update R-scripts which userBDATPRO and now should be updated to userBDAT. Internally,gsub is used.
outpath can be (i) a filename, then the newly generated fileis stored under that name in theinpath directory, (ii) a directory,then theinpath-filename is used with prefixedrbdat_, (iii) acomplete path (directory name and file name), then this is used to store thefile, (iv) NULL, then the inpath is used with prefixedrbdat_ to theinpath filename.
Value
a character holding path and filename of the updated file
Examples
## Not run: p <- tempdir()f <- "rbdatpro.r"tx <- c("require(rBDATPRO)", "library(rBDATPRO)", "rBDATPRO::getDiameter(list(spp=1, D1=30, H=27))")pf <- file.path(p, f)writeLines(tx, con=pf)file.exists(pf)list.files(p)# file.show(pf)## define different output specsoutpath1 <- file.path(tempdir(), "devel/rbdatScript.r")outpath2 <- poutpath3 <- "rbdatScript.r"(updated_file <- updateBdatNamespace(pf, outpath = NULL))list.files(p)# file.show(updated_file)(updated_file <- updateBdatNamespace(pf, outpath1))list.files(file.path(p, "devel"))# file.show(updated_file)(updated_file <- updateBdatNamespace(pf, outpath2))list.files(p)# file.show(updated_file)(updated_file <- updateBdatNamespace(pf, outpath3))list.files(p)# file.show(updated_file)## End(Not run)