Author: Christian Vonderach

# Extend TapeR by implementing sorting and related aspects of forestry in R

#### Christian Vonderach

#### 26 Juli, 2025

## How to get the R-Package

    remotes::install_gitlab(„vochr/tapes“, build_vignettes = TRUE)

## Basic

This R-Package extends, adapts and realizes the methodological taper curve development package TapeR for the context of the German National Forest Inventory (NFI). For that purpose new taper curve models were developed on extensive data from several German research stations.

## Functionality

The package aims at providing functions to evaluate TapeR-base taper curves with respect to diameter at given height, height of given diameter, estimating double bark thickness, providing volumes of total taper curve and parts of it, estimating total aboveground biomass and components of it. The following section provide examples on the data structure and how the functions can be used.

### S4-classes

The package establishes two S4-classes, which define requirements on the data applied to the functions. The tprTrees-class obviously defines trees, but with a focus on sectional measurements. With that, one can provide as many diameters (and their measurement heights) to precisely follow its taper curve. But similarly, one can only provide one diameter and its measurement height for subsequent use of the package functions.

    help("tprTrees-class")

For estimating roundwood assortments, there is an additional S4-class parSort which defines the sorting parameters.

    help("parSort-class")

### handled tree species

The tree species list is taken from the predecessor taper curve model BDAT. Indeed, there are only eight taper curve models, but the other tree species are mapped to these eight. For future releases this might chance if further data leads to the development of additional taper curve models.

    require(TapeS)

    ## Lade nötiges Paket: TapeS

    ## This is TapeS 0.14.1
    ## Option 'TapeS_Rfn' set to 'sig2'. See '?setTapeSoptions' for details.

    tprSpeciesCode(inSp = NULL, outSp = NULL)

    ##    ID kurz            lang short                long            scientific
    ## 1   1   Fi          Fichte    NS       Norway spruce           Picea abies
    ## 2   2   SF    Sitka-Fichte    SS        Sitka spruce      Picea sitchensis
    ## 3   3   Ta           Tanne   ESF European silver fir            Abies alba
    ## 4   4   KT    Kuestentanne    GF           Grand fir         Abies grandis
    ## 5   5  Kie          Kiefer    SP         Scotch pine      Pinus sylvestris
    ## 6   6   SK   Schwarzkiefer   AUP       Austrian pine           Pinus nigra
    ## 7   7   WK Weymouthskiefer   WEP       Weymouth pine         Pinus strobus
    ## 8   8   DG       Douglasie    DF         Douglas fir Pseudotsuga menziesii
    ## 9   9   La         Laerche   XLA               larch            Larix spp.
    ## 10 10   EL  Europ. Laerche   ELA      European larch         Larix decidua
    ## 11 11   JL    Jap. Laerche   JLA      Japanese larch       Larix kaempferi
    ## 12 12   Th           Thuja    RC   Western red cedar         Thuja plicata
    ## 13 13   Ts           Tsuga    WH     Western hemlock    Tsuga heterophylla
    ## 14 14   SN             sNB    XC      other conifers     Coniferales trees
    ## 15 15   Bu           Buche    BE               beech       Fagus sylvatica
    ## 16 16   HB       Hainbuche   HBM            hornbeam      Carpinus betulus
    ## 17 17   Ei           Eiche    OK oak (robur/petraea)          Quercus spp.
    ## 18 18   RE        Roteiche   ROK             Red oak         Quercus rubra
    ## 19 19   Pa          Pappel   XPO              poplar          Populus spp.
    ## 20 20   BP    Balsampappel   BPO       Balsam poplar   Populus balsamifera
    ## 21 21   Es           Esche    AH                 ash    Fraxinus excelsior
    ## 22 22   Ah           Ahorn   XAH               maple             Acer spp.
    ## 23 23   BA       Bergahorn    SY            sycamore   Acer pseudoplatanus
    ## 24 24   SA      Spitzahorn   NOM        Norway maple      Acer platanoides
    ## 25 25   FA       Feldahorn    FM         Field maple        Acer campestre
    ## 26 26   Bi           Birke   XBI               birch           Betula spp.
    ## 27 27   Li           Linde    LI           lime tree            Tilia spp.
    ## 28 28   Er            Erle    AR               alder            Alnus spp.
    ## 29 29  Kir         Kirsche   WCH         Wild cherry          Prunus avium
    ## 30 30   Ul            Ulme    EM                 elm            Ulmus spp.
    ## 31 31   Ro         Robinie    BL        black locust  Robinia pseudoacacia
    ## 32 32   El        Elsbeere   WST   Wild service tree     Sorbus torminalis
    ## 33 33   Ka        Kastanie    SC      Sweet chestnut       Castanea sativa
    ## 34 34   We           Weide   XWL              willow            Salix spp.
    ## 35 35   LB             sLB    XB   other broadleaves   Magnoliopsida trees
    ## 36 36   VB      Vogelbeere   ROW               rowan      Sorbus aucuparia
    ## 37 37  BU_          Buche_   BE_              beech_      Fagus sylvatica_
    ## 38 38  Ei_          Eiche_   OK_                oak_         Quercus spp._
    ## 39 39 REi_       Roteiche_  ROK_            Red oak_        Quercus rubra_

### species mapping

Beside the taper curve models, mapping between species is required also for double bark thickness, biomass functions (total aboveground and component biomass), minimum cutting diameter, the amount of crown wood in deciduous tree species and the volume for small trees according to FAO.

    BaMap(Ba = NULL, type = NULL)

    ##    Schaftform Rinde Az uvDh mAS Biomasse BmComp VolFao Formigkeit
    ## 1           1     1  1    0   0        1      1      1          1
    ## 2           1     1  1    0   0        1      1      1          1
    ## 3           2     2  3    0   0        2      2      2          2
    ## 4           2     2  3    0   0        2      2      2          2
    ## 5           4     4  4    0   0        4      3      4          4
    ## 6           4     8  4    0   0        4      3      4          4
    ## 7           4     9  4    0   0        4      3      4          4
    ## 8           3     3  1    0   0        3      4      3          3
    ## 9           5     6  5    0   0        5      4      5          5
    ## 10          5     6  5    0   0        5      4      5          5
    ## 11          5     7  5    0   0        5      4      5          5
    ## 12          1     1  1    0   0        1      1      1          1
    ## 13          1     1  1    0   0        1      1      1          1
    ## 14          1     2  1    0   0        1      1      1          1
    ## 15          6    10  6    1   1        6      5      6          6
    ## 16          6    18  6    1   1        9      6      7          6
    ## 17          7    11  7    2   2        7      6      7          7
    ## 18          8    14  7    2   2        7      6      7          8
    ## 19          8    25  6    2   2       17      5      6          8
    ## 20          8    25  6    2   2       17      5      6          8
    ## 21          6    17  6    2   2        8      8      7          6
    ## 22          6    15  6    1   1       10      7      7          6
    ## 23          6    15  6    1   1       10      7      7          6
    ## 24          6    15  6    1   1       11      7      7          6
    ## 25          6    21  6    1   1       10      7      7          6
    ## 26          6    21  6    1   1       15      5      6          9
    ## 27          6    16  6    1   1       12      5      6          6
    ## 28          6    28  6    1   1       16      5      6          6
    ## 29          6    26  6    1   1        6      5      6          6
    ## 30          6    20  6    1   1       14      5      6          6
    ## 31          6    19  7    2   2       13      5      6          6
    ## 32          6    23  6    1   1        6      5      6          6
    ## 33          7    11  6    1   1        6      5      6          7
    ## 34          6    12  6    1   1       18      5      6          6
    ## 35          6    12  6    1   1        6      5      6          6
    ## 36          6    26  7    2   1        6      5      6          6
    ## 37          9    10  6    1   1        6      5      6          6
    ## 38         10    11  7    2   2        7      6      7          7
    ## 39         11    14  7    2   2        7      6      7          8

### Defining a tprTrees object

    require(TapeS)
    obj <- tprTrees(spp=c(1, 3),
                    Hm=list(c(1.3, 5, 7), c(1.3)),
                    Dm=list(c(27, 23.5, 22.4), c(27)),
                    Ht=c(27, 30))
    Hx <- c(1.3, 5, 7)

### Diameter estimation

Diameter estimation from the developed taper curves via the empirical best linear unbiased predictor (EBLUP, see Kublin et al. (2013)) not necessarily
passed through the observations. This behaviour can be forced if the residual variance is set to zero. The package offers to set an option ‘TapeS_R0’ which, by default, is set to FALSE and uses full information from the models.

If one wants to force the taper curves through given (measured) diameters, one can do so by setting TapeS::setTapeSoptions(). See further down.

    tprDiameter(obj, Hx = Hx) # R0=TRUE, taper curve through measurements

    ##          [,1]     [,2]     [,3]
    ## [1,] 26.98207 23.53026 22.38791
    ## [2,] 27.00847 24.30814 23.31787

    tprDiameter(obj, Hx = Hx, bark = FALSE)

    ##          [,1]     [,2]     [,3]
    ## [1,] 25.51535 22.21057 21.11821
    ## [2,] 25.32629 22.77738 21.84264

    tprDiameter(obj, Hx = Hx, interval = "prediction")

    ##      tree  Hx      lwr      EDx      upr
    ## [1,]    1 1.3 25.69324 26.98207 28.27089
    ## [2,]    1 5.0 22.38707 23.53026 24.67345
    ## [3,]    1 7.0 21.21585 22.38791 23.55997
    ## [4,]    2 1.3 25.07738 27.00847 28.93955
    ## [5,]    2 5.0 21.90235 24.30814 26.71393
    ## [6,]    2 7.0 20.82588 23.31787 25.80986

The diameter are evaluated at position Hx for each tree. If only one diameter is required, e.g. for relative height, the parameter cp=FALSE (no cartesian product) can be used

    tprDiameter(obj, Hx = 0.3*Ht(obj), interval = "prediction", cp=FALSE)

    ##      tree  Hx      lwr      EDx      upr
    ## [1,]    1 8.1 20.51562 21.76156 23.00750
    ## [2,]    2 9.0 19.75799 22.38323 25.00847

### Height estimation

    tprHeight(obj, Dx = c(10, 9, 8, 7))

    ##          [,1]     [,2]     [,3]     [,4]
    ## [1,] 21.68562 22.37393 23.01733 23.62004
    ## [2,] 25.14243 25.79791 26.40098 26.95868

    tprHeight(obj, Dx = c(10, 9, 8, 7), bark = FALSE)

    ##          [,1]     [,2]     [,3]     [,4]
    ## [1,] 21.16237 21.93210 22.64808 23.31524
    ## [2,] 24.56976 25.32251 26.00833 26.63661

### Estimation of double bark thickness

    tprBark(obj, Hx = c(1, 2, 3))

    ##          [,1]     [,2]     [,3]
    ## [1,] 1.512889 1.404739 1.371391
    ## [2,] 1.712393 1.632778 1.592503

### Volume estimation

    tprVolume(obj) # default is Vfm

    ## [1] 0.7155448 0.8559027

    tprVolume(obj, AB = list(A=0, B=7), iAB=c("h", "dob"), bark=TRUE) # same

    ## [1] 0.7155448 0.8559027

    Vfm(obj) # wrapper

    ## [1] 0.7155448 0.8559027

    VolR(obj) # wrapper

    ## [1] 0.7155448 0.8559027

    Efm(obj, stH = 0.01) # default

    ## [1] 0.6148924 0.7297650

    VolE(obj)

    ##   tree       vol
    ## 1    1 0.5569941
    ## 2    2 0.6604166

    VolFAO(obj)

    ## [1] 0.6977114 0.8395405

    Vfm_phys(obj) # takes a while

    ## [1] 0.7238518 0.8588418

    Efm_phys(obj)

    ## [1] 0.6205634 0.7317585

    tprVolume(obj, AB = list(A=0.01*Ht(obj), B=7, sl=0.01), iAB = c("H", "Dob"), bark=FALSE)

    ## [1] 0.6205634 0.7317585

### Estimation of roundwood assortments

    tprAssortment(obj) ## default assortment parameters

    ##    tree sort height    length       mdm       zdm         vol
    ## 3     1  sth   0.27 19.000000 18.847735 11.721560 0.530104882
    ## 5     1   ih  19.46  1.000000 10.961870 10.384459 0.009437547
    ## 6     1  nvd  20.46  3.160039  8.385469  6.051613 0.017451670
    ## 31    2  sth   0.30 19.000000 19.850787 14.712666 0.588029258
    ## 51    2   ih  19.49  4.000000 12.854161 10.818101 0.051908368
    ## 61    2  nvd  23.49  3.468678  8.670170  5.987748 0.020479017

    pars <- parSort(stH=0.2, Lxh=c(1, 1.5), fixN=2, fixL=4)
    tprAssortment(obj, pars = pars)

    ##    tree  sort height    length       mdm       zdm        vol
    ## 1     1    hx  0.200  1.000000 27.305190 25.115321 0.05855720
    ## 2     1 fix01  1.200  4.000000 22.520121 21.382661 0.15932770
    ## 3     1 fix02  5.240  4.000000 20.271255 19.146289 0.12909551
    ## 4     1   sth  9.280 10.900000 15.870577 10.710667 0.21562635
    ## 7     1   nvd 20.289  3.331039  8.501393  6.051613 0.01890818
    ## 11    2    hx  0.200  1.500000 25.222573 24.090990 0.07494798
    ## 21    2 fix01  1.700  4.000000 22.729877 21.733041 0.16230954
    ## 31    2 fix02  5.740  4.000000 20.804923 19.876919 0.13598222
    ## 41    2   sth  9.780 13.700000 16.647170 10.829273 0.29818878
    ## 71    2   nvd 23.617  3.341678  8.582446  5.987748 0.01933199

### Biomass estimation

#### total aboveground biomass

    tprBiomass(obj) # bwi-biomass

    ## [1] 313.5984 394.2241

#### component biomass

For this package the biomass functions of Vonderach et al. (2018) have been extended to include predictors D03 and crown length for the prediction of several components. Although these models can estimate absolute biomass, in this context they are used to predict the share of each component, which is multiplied by total aboveground biomass.

    tprBiomass(obj, component = c("sw", "sb", "ndl"))

    ##         sw       sb      ndl
    ## 1 236.2177 21.88162 16.53454
    ## 2 250.8663 39.55823 55.37832

    tprBiomass(obj, component = c("all"))

    ##        stw       stb       sw       sb      fwb      ndl      agb
    ## 1 9.856526 0.9110677 236.2177 21.88162 28.19688 16.53454 313.5984
    ## 2 6.161245 1.1307266 250.8663 39.55823 41.12920 55.37832 394.2241

## Option: Taper curve evaluation

In TapeR-package, the taper curve of a tree with given diameter- and height measurements is as a default realised using the estimated best linear unbiased predictor (see Kublin et al. 2013, p.987). This means, that all diameters and volume predictions are estimated using the intrinsic error structure of the fitted taper curve model. Hence the taper curve not necessarily passes through the measured diameter.

For the possibility of forcing the taper curves through the measured diameters, the TapeR-package has been extended to allow for explicitly determining the assumed residual variance. See ?TapeR::resVar.

To apply a modification of the residual variance in TapeS, one can set a special package option (all called functions react to this option) or define the options as a parameter in each function. The package option is set by TapeS_Rfn = list(fn=“zero”), here with a zero-function to force interpolation.

    setTapeSoptions(Rfn = list(fn="zero"))
    tprDiameter(obj, Hx=1.3)

    ## [1] 27 27

    setTapeSoptions(Rfn = list(fn="sig2"))
    tprDiameter(obj, Hx=1.3)

    ## [1] 26.98207 27.00847

By default, this option is set to “sig2” on load of the package, hence, the residual variance of the model is used (default behaviour of TapeR). Other functions are also available, e.g. “linear”, “laglinear”, “biliniar”, “dnorm” and “dlnorm”. Most function allow for defining a point of zero variance. The latter two are based on the normal and log-normal distribution and allow for a standard deviation term.

Please note: setting a zero variance should not be overstrained. It is mainly implemented to preserve diameter in breast height (dbh) measurements for trees of e.g. inventory data. If one is about to apply the TapeS-functions to sectional data, where a lot of diameter measurements are available, the TapeS_Rfn-Option should left as is or set to sig2 via TapeS::setTapeSoptions(Rfn = list(fn=“sig2”)).

## Option: improve monotonicity of taper curves

Depending on the size and measurements of (especially small) trees, it sometimes might happen, that the calibrated taper curves have an increasing diameter sequence at the stem foot:

    plot(tprTrees(spp=3, Dm=7.9, Hm=1.3, Ht=12, ), mono=FALSE)

To avoid such implausible taper curves, internally an additional support “measurement” at 1% of tree height is added to the set of measurements. This extra measurement is based on the ratio between 5% and 1% of tree height of the population average curve. With that, taper curves usually are monotonically decreasing:

    plot(tprTrees(spp=3, Dm=7.9, Hm=1.3, Ht=12, ), mono=TRUE)

By default, mono is set to TRUE (must not be given) via options(“TapeS_mono”), hence, all non-monotonic curves (check at initialisation), are amended by an additional support diameter.

## References

Kublin, E., J. Breidenbach and G. Kaendler (2013). “A flexible stem taper and volume prediction method based on mixed-effects B-spline regression.” European Journal of forest research 132(5-6): 983-997.

Vonderach, C., G. Kändler and C. F. Dormann (2018). “Consistent set of additive biomass functions for eight tree species in Germany fit by nonlinear seemingly unrelated regression.” Annals of Forest Science 75(2): 49.

## Contact

christian.vonderach@forst.bwl.de

Forest Research Institute Baden-Württemberg by order of Thünen Institute of Forest Ecosystems / Forest resources and climate protection