getSpeciesCode {rBDAT} | R Documentation |
Get BDAT species code or transform it to a name.
Description
Function to get BDAT species code, or transform it to a german or english name, possibly an abbreviated version or even a scientific name
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 either
a numeric vector of values between 1 and 36 or a character vector of species
names. Possible names are those which could be return values. One can get all
names and the respective species code by calling the function with
inSP=NULL
and outSP=NULL
(the default).
English species names and codes are now (June 2025) taken from the German
National Forest Inventory (version=2
, default), in the previous
version (version=1
) the English species names were taken from
https://www.forestry.gov.uk/pdf/PF2011_Tree_Species.pdf/$FILE/PF2011_Tree_Species.pdf
while 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 column long
, not to column short
.
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)), while throwing 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 returned data.frame, are silently dropped.
Value
vector or data.frame, depending on length of 'outSp'.
Examples
getSpeciesCode(inSp = NULL, outSp = NULL) ## the default
getSpeciesCode() ## the same
getSpeciesCode(outSp = "scientific")
getSpeciesCode(inSp = c(1, 2)) ## giving codes
getSpeciesCode(inSp = c(1, 2, -1, 37)) ## values outside [1, 36] are given code 1
getSpeciesCode(inSp = c(1, 2), outSp = c("scientific")) ## output a vector
getSpeciesCode(inSp = c("Bu", "Fi")) ## asking for codes of abbreviated german names
getSpeciesCode(inSp = c("Bu", "Fi", "Bu")) ## order is preserved
getSpeciesCode(inSp = c("Buche", "Fichte")) ## asking for codes of german names
getSpeciesCode(inSp = c("BE", "NS")) ## ... abbreviated english names
getSpeciesCode(inSp = c("Common beech", "European spruce")) ## ... english names
getSpeciesCode(inSp = c("Fagus sylvatica", "Picea abies")) ### ... scientific names
# get previous species look-up table
getSpeciesCode(version=1)
# as compared to the current version
getSpeciesCode() # or explicitly
getSpeciesCode(version=2)