data_coercion {TapeS} | R Documentation |
coerce different data sources into class 'tprTrees'
Description
coercion functions to make NFI, segment and 'BDAT' data available as 'tprTrees' objects
Usage
nfi_as_tprtrees(nfi, mapping = NULL)
seg_as_tprtrees(seg, mapping = NULL)
bdat_as_tprtrees(bdat)
Arguments
nfi |
data.frame with tree measurements as provided by german NFI |
mapping |
mapping of column names |
seg |
data.frame with measured tree segments, see details. |
bdat |
data.frame holding data to process with rBDAT |
Details
The coerced data is automatically checked for validity by the class
constructor. For available species codes see tprSpeciesCode
.
When coercing NFI (National forest inventory, BWI) data, one need
to provide the columns BaTpr
(species code), Bhd
(Dbh, [mm]),
D03, [mm]
(diameter in 30% of tree height) and Hoehe
(tree
height, [dm]). Optionally, one can provide H1
(measurement height of
Bhd
, [dm]), H2
(measurement height of D03
, [dm]) as well
as sHt
(measurement error of tree height, i.e. standard deviation [dm]);
otherwise these are assumed to be 1.3m, 30% of tree height and 0 (zero),
respectively.
Additionally, the NFI database stores diameter as [mm] and height as [dm]; it
is *not* necessary to transform to [cm] and [m], as the function does this.
Equally, sHt
[dm] is transformed to sHt
[m].
Keep in mind that species codes of NFI are different from the taper models for historical reasons (c.f. BDAT). Use the NFI table ('x_Ba') to map species codes beforehand (see examples).
Sectional measurements provide more information about the trunk of
a tree and are usually stored in a different way. They exhibit an arbitrary
amount of diameter measurements which also might vary from tree to tree.
Hence, seg_as_tprtrees
expects a data.frame with columns
Id
, BaTpr
(species code), Dm
(diameter measured, [cm]),
Hm
(height of Dm
, [m]) and optionally Ht
(height of
tree, [m]). Tree height Ht
can be included to
Dm
-Hm
-pairs with Dm
being zero
(e.g. Dm
=0, Hm
=25). If Ht
is given, it gains priority.
coercing object of class 'datBDAT' from R-Package "rBDAT" into class 'tprTrees'
Value
an object of class 'tprTrees', see tprTrees-class
Functions
-
nfi_as_tprtrees()
: coercion of German NFI data -
seg_as_tprtrees()
: coercion of segmented data to class 'tprTrees' -
bdat_as_tprtrees()
: coercion of bdat data
See Also
tprTrees-class
, tprTrees
,
tprSpeciesCode
Examples
# NFI data usually stored as integer and units: diameter=[mm] and height=[dm]
nfi <- data.frame(BaTpr=1L, Bhd=300L, D03=270L, Hoehe=250L)
tpr <- nfi_as_tprtrees(nfi)
tpr
tpr@sHt # defaults to 0
# one can provide measurement heights explicitly
nfi <- data.frame(spp=1, Bhd=300, H1=12, D03=270, H=250)
nfi_as_tprtrees(nfi, mapping=c(spp="BaTpr", H="Hoehe"))
# measurement error in height
nfi <- data.frame(BaTpr=1L, Bhd=300L, D03=270L, Hoehe=250L, sHt=15)
tpr <- nfi_as_tprtrees(nfi)
tpr@sHt
## coercing sectional measurements
data(DxHx.df, package = "TapeR")
DxHx.df$BaTpr <- 1 # Norway spruce
segtprtrees <- seg_as_tprtrees(DxHx.df, mapping=c(Dx="Dm", Hx="Hm"))
## extract tree height from Dm-Hm measurements if not given explicitly
DxHx.df$Ht <- NULL # remove height, as already included with Dm=0
segtprtrees <- seg_as_tprtrees(DxHx.df, mapping=c(Dx="Dm", Hx="Hm"))
segtprtrees
if(require(rBDAT)){
bdt <- buildTree(list(spp=1, D1=30, D2=28, H2=7, H=25))
bdat_as_tprtrees(bdt)
}