Load the library, an example density profile and then trim it and detrend it. While ring detection will work on untrimmed and undetrended density profiles, you will obtain better results by trimming and detrending the density profile.
Tree rings can identified using dprings
function, which
will identify local peaks and valleys inside the density profile. It
will return a data frame by default, where the value is the horizontal
index of the peak/valley:
rings <- dprings(dp.detrended)
head(rings)
#> value type amplitude
#> 1 19 peak 438.7755
#> 37 170 valley 400.5265
#> 2 248 peak 440.3054
#> 38 436 valley 407.3829
#> 3 506 peak 484.3507
#> 39 613 valley 417.8074
When dprings
is called with
return.plot = TRUE
, the function will return a diagnostic
plot. The green points are valleys, blue points are peaks and red points
were either a repetition of peak or valley that was automatically
excluded.
The dashed line on the graph is the minimum peak value limit,
represented by the overall mean of the profile. You could also remove
some noise by smoothing the profile first by adding the argument
smooth = TRUE
. This applies a LOESS regression with a given
span and removes some of the noise.
Different tree species will require different parameters, try to
adjust either pps
or threshold.sd
to get
better results. Best results are expected in softwoods, as they have a
clearer transition between early and late wood.
To extract ring widths from the ring detection, use
get_RW
on the data frame returned by dprings
,
which will a vector of peak-to-peak distances representing ring widths.
The unit is dictated by the unit of the original density profile, which
can be extracted using dp$footer$xUnit
.
get_RW(rings)
#> [1] 229 258 175 633 163 191 290 156 455 226 254 329 135 193 287 257 384 277 201
#> [20] 298 205 276 241 167 263 290 239 146 323 267 266 315 259
dp$footer$xUnit
#> [1] "1/100 mm"
length(get_RW(rings))
#> [1] 33
Overall, in this particular density profile we have detected 33 rings, the values can then be further examined as demonstrated below.