Author: Narcisse Yehouenou
Date: 2023-02-07

# dendrometry: Narcisse’ Useful Functions (in Progress)

#### Narcisse Yehouenou

#### 2023-02-07

# 1 The `dendrometry` r package

## 1.1 Description

The r package `dendrometry` is an implementation in R language of forests estimations methods such as dendrometric parameters of trees and structural parameters of tree populations. The objective is to provide an user-friendly R package for researchers, ecologists, foresters, statisticians, loggers and others persons who deal with forest inventory data. Useful conversion of angle value from degree to radian, conversion from angle to slope (in percentage) and their reciprocals as well as principal angle determination are also included. Position and dispersion parameters usually found in forest studies are implemented. The package contains Fibonacci series, its extensions and the Golden Number computation.

## 1.2 Package citation

Please cite this package in publication or anywhere it comes to be useful for you. Using `citation` R function is a simple way to get this package references on R interface. The function also provides a BibTeX entry for La-TeX users.

    citation("dendrometry")

    #>
    #> To cite package 'dendrometry' in publications use:
    #>
    #>   Narcisse Yehouenou (2023). dendrometry: Forest Estimations and
    #>   Dendrometric Computations. R package version 0.0.2.
    #>
    #> Une entrée BibTeX pour les utilisateurs LaTeX est
    #>
    #>   @Manual{,
    #>     title = {dendrometry: Forest Estimations and Dendrometric Computations},
    #>     author = {Narcisse Yehouenou},
    #>     year = {2023},
    #>     note = {R package version 0.0.2},
    #>   }

# 2 Forest estimations: Structural parameters

Before use the package, load it first.

    library(dendrometry)

## 2.1 `Tree` data

Let consider the package built-in `Tree` data.

    data("Tree")
    head(Tree)
    #>   circum dist   up  down  fut
    #> 1  345.0   17 47.2 -16.8 33.9
    #> 2  241.3   15 41.9 -14.4 30.0
    #> 3  255.1   13 47.3  -1.7 38.7
    #> 4  227.8   15 44.2 -12.2 36.6
    #> 5  283.4   15 52.0  -4.9 27.2
    #> 6  155.0   15 30.6  -6.4 25.5

To see `Tree`data description, use

    help("Tree")

## 2.2 Diameter at Breast Height (DBH)

Use `dbh` function to estimate trees diameters (DBH).Type `?dbh` for help.

    Tree$DBH <- dbh(Tree$circum)
    head(Tree)

    #>   circum dist   up  down  fut       DBH
    #> 1  345.0   17 47.2 -16.8 33.9 109.81691
    #> 2  241.3   15 41.9 -14.4 30.0  76.80818
    #> 3  255.1   13 47.3  -1.7 38.7  81.20085
    #> 4  227.8   15 44.2 -12.2 36.6  72.51099
    #> 5  283.4   15 52.0  -4.9 27.2  90.20902
    #> 6  155.0   15 30.6  -6.4 25.5  49.33803

## 2.3 Height estimation

Use `height` function to estimate tree height.Type `?height` for help.

    Tree$upHeight <- height(distance = Tree$dist, top = Tree$up, base = Tree$down,
                            type = "angle", angleUnit = "deg")
    Tree$futHeight <- height(distance = Tree$dist, top = Tree$fut, base = Tree$down,
                            type = "angle", angleUnit = "deg")
    head(Tree)

    #>   circum dist   up  down  fut       DBH upHeight futHeight
    #> 1  345.0   17 47.2 -16.8 33.9 109.81691 23.49093 16.556129
    #> 2  241.3   15 41.9 -14.4 30.0  76.80818 17.31008 12.511599
    #> 3  255.1   13 47.3  -1.7 38.7  81.20085 14.47380 10.800795
    #> 4  227.8   15 44.2 -12.2 36.6  72.51099 17.82998 14.383098
    #> 5  283.4   15 52.0  -4.9 27.2  90.20902 20.48508  8.994906
    #> 6  155.0   15 30.6  -6.4 25.5  49.33803 10.55349  8.837153

### 2.3.1 Let round data

    Tree$DBH <- round(Tree$DBH, 2)
    Tree$upHeight <- round(Tree$upHeight, 2)
    Tree$futHeight <- round(Tree$futHeight, 2)
    Tree

    #>    circum dist   up  down  fut    DBH upHeight futHeight
    #> 1   345.0   17 47.2 -16.8 33.9 109.82    23.49     16.56
    #> 2   241.3   15 41.9 -14.4 30.0  76.81    17.31     12.51
    #> 3   255.1   13 47.3  -1.7 38.7  81.20    14.47     10.80
    #> 4   227.8   15 44.2 -12.2 36.6  72.51    17.83     14.38
    #> 5   283.4   15 52.0  -4.9 27.2  90.21    20.49      8.99
    #> 6   155.0   15 30.6  -6.4 25.5  49.34    10.55      8.84
    #> 7   247.0   14 52.4 -14.0 34.9  78.62    21.67     13.26
    #> 8   313.9   13 46.8 -10.6 32.0  99.92    16.28     10.56
    #> 9   337.5   17 39.6 -11.2 23.1 107.43    17.43     10.62
    #> 10  312.1   17 51.7 -18.2 38.1  99.34    27.12     18.92

## 2.4 Compute slope

Ones could need converting angle values to slope. The `angle2slope` function does it easily. The reciprocal of this function is `slope2angle`.

    Tree$up.slope <- angle2slope(Tree$up)
    Tree$up.slope <- round(Tree$up.slope)
    Tree

    #>    circum dist   up  down  fut    DBH upHeight futHeight up.slope
    #> 1   345.0   17 47.2 -16.8 33.9 109.82    23.49     16.56      108
    #> 2   241.3   15 41.9 -14.4 30.0  76.81    17.31     12.51       90
    #> 3   255.1   13 47.3  -1.7 38.7  81.20    14.47     10.80      108
    #> 4   227.8   15 44.2 -12.2 36.6  72.51    17.83     14.38       97
    #> 5   283.4   15 52.0  -4.9 27.2  90.21    20.49      8.99      128
    #> 6   155.0   15 30.6  -6.4 25.5  49.34    10.55      8.84       59
    #> 7   247.0   14 52.4 -14.0 34.9  78.62    21.67     13.26      130
    #> 8   313.9   13 46.8 -10.6 32.0  99.92    16.28     10.56      106
    #> 9   337.5   17 39.6 -11.2 23.1 107.43    17.43     10.62       83
    #> 10  312.1   17 51.7 -18.2 38.1  99.34    27.12     18.92      127

## 2.5 Individual basal area

The basal area of each tree is computed with `basal_i` function.

    Tree$basal <- basal_i(dbh = Tree$DBH/100)
    Tree$basal <- round(Tree$basal, 4)
    Tree

    #>    circum dist   up  down  fut    DBH upHeight futHeight up.slope  basal
    #> 1   345.0   17 47.2 -16.8 33.9 109.82    23.49     16.56      108 0.9472
    #> 2   241.3   15 41.9 -14.4 30.0  76.81    17.31     12.51       90 0.4634
    #> 3   255.1   13 47.3  -1.7 38.7  81.20    14.47     10.80      108 0.5178
    #> 4   227.8   15 44.2 -12.2 36.6  72.51    17.83     14.38       97 0.4129
    #> 5   283.4   15 52.0  -4.9 27.2  90.21    20.49      8.99      128 0.6391
    #> 6   155.0   15 30.6  -6.4 25.5  49.34    10.55      8.84       59 0.1912
    #> 7   247.0   14 52.4 -14.0 34.9  78.62    21.67     13.26      130 0.4855
    #> 8   313.9   13 46.8 -10.6 32.0  99.92    16.28     10.56      106 0.7841
    #> 9   337.5   17 39.6 -11.2 23.1 107.43    17.43     10.62       83 0.9064
    #> 10  312.1   17 51.7 -18.2 38.1  99.34    27.12     18.92      127 0.7751

DBH is divided by 100 in order to convert DBH to meter (m). This conversion is optional and depends on the study methodology.

## 2.6 Lorey’s mean height

The Lorey’s mean height is computed via `loreyHeight` function.

    Lorey <- loreyHeight(basal = Tree$basal, height = Tree$upHeight)
    Lorey

    #> [1] 19.65526

Note: Simple mean of height is different from Lorey’s mean height.

    #> Mean of Height(m)   Lorey height(m)
    #>          18.66400          19.65526

## 2.7 Mean diameter

The mean diameter is computed with `diameterMean` function.

    Dm <- diameterMean(Tree$DBH)
    Dm

    #> [1] 88.29404

Note: Simple mean of diameter is different from mean diameter (Dm).

    #> Simple mean of Diameter(cm)           Mean diameter(cm)
    #>                    86.52000                    88.29404

# 3 Logging: Dendrometric characteristics

This section is illustrated with the `Logging` data set.

## 3.1 The `Logging` dataset

The `Logging` data are in a data frame with twenty five observations and eight variables assumed collected on trees and/or logs. Type `?Logging` for details.

    data("Logging")
    summary(Logging)

    #>      tree              hauteur      diametreMedian  perimetreMedian
    #>  Length:24          Min.   :12.10   Min.   :38.80   Min.   :122.0
    #>  Class :character   1st Qu.:13.60   1st Qu.:62.15   1st Qu.:195.3
    #>  Mode  :character   Median :14.30   Median :72.15   Median :226.5
    #>                     Mean   :14.33   Mean   :71.49   Mean   :224.6
    #>                     3rd Qu.:15.30   3rd Qu.:83.90   3rd Qu.:263.6
    #>                     Max.   :15.70   Max.   :94.20   Max.   :296.0
    #>  perimetreSection diametreSection perimetreBase    diametreBase
    #>  Min.   : 97.6    Min.   :31.10   Min.   :158.6   Min.   : 50.50
    #>  1st Qu.:156.3    1st Qu.:49.73   1st Qu.:253.9   1st Qu.: 80.80
    #>  Median :181.2    Median :57.70   Median :294.5   Median : 93.75
    #>  Mean   :179.7    Mean   :57.19   Mean   :292.0   Mean   : 92.94
    #>  3rd Qu.:210.9    3rd Qu.:67.12   3rd Qu.:342.7   3rd Qu.:109.08
    #>  Max.   :236.8    Max.   :75.40   Max.   :384.8   Max.   :122.50

## 3.2 `factorize` a dataset

The variable `tree` is considered as character rather than factor. To overcome that and make easier manipulation one changes character variables to factor variables. To do that for whole dataset, use function `factorize`. Type `?factorize` for help.

    class(Logging$tree)

    #> [1] "character"

    Logging <- factorize(data = Logging)
    class(Logging$tree)

    #> [1] "factor"

    summary(Logging)

    #>           tree      hauteur      diametreMedian  perimetreMedian
    #>  Afzelia    :2   Min.   :12.10   Min.   :38.80   Min.   :122.0
    #>  Danielia   :4   1st Qu.:13.60   1st Qu.:62.15   1st Qu.:195.3
    #>  Eucalyptus :2   Median :14.30   Median :72.15   Median :226.5
    #>  Isoberlinia:5   Mean   :14.33   Mean   :71.49   Mean   :224.6
    #>  Khaya      :6   3rd Qu.:15.30   3rd Qu.:83.90   3rd Qu.:263.6
    #>  Pterocarpus:5   Max.   :15.70   Max.   :94.20   Max.   :296.0
    #>  perimetreSection diametreSection perimetreBase    diametreBase
    #>  Min.   : 97.6    Min.   :31.10   Min.   :158.6   Min.   : 50.50
    #>  1st Qu.:156.3    1st Qu.:49.73   1st Qu.:253.9   1st Qu.: 80.80
    #>  Median :181.2    Median :57.70   Median :294.5   Median : 93.75
    #>  Mean   :179.7    Mean   :57.19   Mean   :292.0   Mean   : 92.94
    #>  3rd Qu.:210.9    3rd Qu.:67.12   3rd Qu.:342.7   3rd Qu.:109.08
    #>  Max.   :236.8    Max.   :75.40   Max.   :384.8   Max.   :122.50

    head(Logging, 4)

    #>          tree hauteur diametreMedian perimetreMedian perimetreSection
    #> 1    Danielia    13.9           94.2           296.0            236.8
    #> 2    Danielia    13.9           92.3           289.9            231.9
    #> 3 Pterocarpus    14.7           90.4           284.0            227.2
    #> 4       Khaya    13.6           90.1           283.1            226.5
    #>   diametreSection perimetreBase diametreBase
    #> 1            75.4         384.8        122.5
    #> 2            73.8         376.8        119.9
    #> 3            72.3         369.2        117.5
    #> 4            72.1         368.1        117.2

    attach(Logging)

## 3.3 The decrease coefficient

This coefficient expresses the ratio between the diameter (or circumference) at mid-height of the bole and the diameter (or circumference) measured at breast height. The `decrease` function is used to compute this coefficient. Type `?decrease` for help.

    Decrease <- decrease(middle = diametreMedian, breast = diametreBase)
    Decrease

    #>  [1] 0.7689796 0.7698082 0.7693617 0.7687713 0.7696381 0.7690941 0.7692308
    #>  [8] 0.7693069 0.7691542 0.7698492 0.7687564 0.7693943 0.7698073 0.7689732
    #> [15] 0.7694038 0.7691415 0.7688679 0.7692308 0.7690323 0.7689189 0.7685590
    #> [22] 0.7692308 0.7694656 0.7683168

## 3.4 The reduction coefficient

The reduction coefficient is the ratio between the difference in size at breast height and mid-height on the one hand, and the size at breast height on the other. It is thus the complement to 1 of the coefficient of decrease. The `reducecoef` function is used to compute the reduction coefficient. Type `?reducecoef` for help.

    Reduce <- reducecoef(middle = diametreMedian, breast = diametreBase)
    Reduce

    #>  [1] 0.2310204 0.2301918 0.2306383 0.2312287 0.2303619 0.2309059 0.2307692
    #>  [8] 0.2306931 0.2308458 0.2301508 0.2312436 0.2306057 0.2301927 0.2310268
    #> [15] 0.2305962 0.2308585 0.2311321 0.2307692 0.2309677 0.2310811 0.2314410
    #> [22] 0.2307692 0.2305344 0.2316832

## 3.5 Metric decay

The average metric decay expresses the difference, in centimeters per meter, between the diameter (or circumference) at breast height and its diameter at mid-height of a stem related to the difference between the height at mid-height and that at breast height. The average metric decay is computed using `decreaseMetric` function.Type `?decreaseMetric` for help.

    DecMetric <- decreaseMetric(dmh = diametreMedian, dbh = diametreBase,
                                mh = hauteur/2)
    DecMetric

    #>  [1] 5.008850 4.884956 4.479339 4.927273 4.314050 3.969466 3.921260 4.905263
    #>  [9] 4.884211 3.606299 4.090909 3.312977 3.909091 3.763636 3.388430 3.618182
    #> [17] 2.992366 3.345133 2.732824 2.826446 2.814159 2.528926 2.745455 1.786260

In case of DBH considered at other height than 1.3 m, the breast height is set via `bh` argument of `decreaseMetric` function.

    DecMetric1.5 <- decreaseMetric(dmh = diametreMedian, dbh = diametreBase,
                                   mh = hauteur/2, bh = 1.5)
    DecMetric1.5

    #>  [1] 5.192661 5.064220 4.632479 5.113208 4.461538 4.094488 4.048780 5.120879
    #>  [9] 5.098901 3.723577 4.245283 3.417323 4.056604 3.905660 3.504274 3.754717
    #> [17] 3.086614 3.467890 2.818898 2.923077 2.917431 2.615385 2.849057 1.842520

## 3.6 Logs and trees volume computation

The wood volume of logs and trees is computed withe `volume` function. Type `?volume` for help. The `Huber`, `Smalian`, `Cone` and `Newton` methods are implemented. When `successive` is set TRUE, the selected method is implemented on all log belonging to the same tree. The sum of logs volume is returned per tree. Type `?volume` for details.

### 3.6.1 On foot or one log tree volume

    #HUBER
    VolHub <- volume(height = hauteur, dm = diametreMedian, method = "huber")
    #SMALIAN
    VolSmal <- volume(height = hauteur, do = diametreBase, ds = diametreSection,
           method = "smalian")
    #CONE
    VolCone <- volume(height = hauteur, do = diametreBase, ds = diametreSection,
           method = "cone")
    #NEWTON
    VolNew <- volume(height = hauteur, do = diametreBase, dm = diametreMedian,
           ds = diametreSection, method = "newton")

Make a data frame of tree volumes per method.

    TreeVol <- data.frame(tree, VolHub, VolSmal, VolCone, VolNew)
    head(TreeVol)

    #>          tree   VolHub  VolSmal   VolCone    VolNew
    #> 1    Danielia 96873.83 112944.4 108908.01 102230.70
    #> 2    Danielia 93005.38 108201.2 104334.35  98070.65
    #> 3 Pterocarpus 94350.47 109874.5 105943.20  99525.14
    #> 4       Khaya 86711.83 101122.3  97501.27  91515.32
    #> 5 Pterocarpus 87789.02 102147.4  98489.52  92575.14
    #> 6 Isoberlinia 92475.21 107778.5 103925.34  97576.30

### 3.6.2 Tree volume from its logs volume sum

Now, let consider the variable `tree` as the tree to which belong the log; such that each observation of the data set stands for characteristics of a log. It’s like trees are cut in many logs. Then those logs are measured. All logs from the same tree have the same value for variable `tree`. Then let compute trees volume with sum of all logs obtained from each tree. The `successive` argument should then be set to `TRUE`.

    #HUBER
    VolHubSuc <- volume(height = hauteur, dm = diametreMedian, method = "huber",
           successive = TRUE, log = tree)
    #SMALIAN
    VolSmalSuc <- volume(height = hauteur, do = diametreBase, ds = diametreSection,
           method = "smalian", successive = TRUE, log = tree)
    #CONE
    VolConSuc <- volume(height = hauteur, do = diametreBase, ds = diametreSection,
           method = "cone", successive = TRUE, log = tree)
    #NEWTON
    VolNewSuc <- volume(height =  hauteur, do = diametreBase, dm = diametreMedian,
           ds = diametreSection, method = "newton", successive = TRUE,
           log = tree)
    VolNewSuc

    #> [1] 278131.9 320197.0 344495.6 286902.0 161669.8 120418.5

    volume(height =  hauteur, do = diametreBase, dm = diametreMedian,
           ds = diametreSection, method = "newton", successive = TRUE, log = tree)

    #> [1] 278131.9 320197.0 344495.6 286902.0 161669.8 120418.5

Make a data frame of tree volumes per method.

    TreeVolSuc <- data.frame(tree = unique(tree), VolHubSuc, VolSmalSuc, VolConSuc, VolNewSuc)
    TreeVolSuc

    #>          tree VolHubSuc VolSmalSuc VolConSuc VolNewSuc
    #> 1    Danielia  263643.9   307108.0  296121.6  278131.9
    #> 2 Pterocarpus  303563.9   353463.3  340809.3  320197.0
    #> 3       Khaya  326485.1   380516.5  366911.6  344495.6
    #> 4 Isoberlinia  271892.6   316921.0  305592.1  286902.0
    #> 5  Eucalyptus  153290.4   178428.7  172041.6  161669.8
    #> 6     Afzelia  114159.4   132936.7  128167.8  120418.5

## 3.7 The shape coefficient

The shape coefficient of the tree is the ratio of the actual volume of the tree to the volume of a cylinder having as base the surface of the section at 1.3 m (or a given breast height) and as length, the height of the tree.

    Shape <- shape(volume = VolNewSuc, height = hauteur, dbh = perimetreMedian)
    Shape

    #>  [1] 0.2907788 0.3489926 0.3699472 0.3351391 0.1866542 0.1318036 0.3402940
    #>  [8] 0.5659296 0.6149093 0.4127833 0.2738388 0.1890187 0.5111624 0.6389570
    #> [15] 0.6461058 0.6190508 0.3122882 0.2813572 0.6422766 0.8675112 1.1465321
    #> [22] 0.9682809 0.6047658 0.6561210