Introduction

This vignette describes the procedures used to obtain a set of taxon entities to be used in medfate, which intend to cover most of the woody plant taxa in Spain, as they are reported in the Spanish National Forest Inventory surveys (Inventario Forestal Nacional or IFN).

The vignette is not self-contained, in the sense that it cannot be reproduced without access to data sets that are not included. Nevertheless, it is intended to serve as example of species parameterization for other regions.

Required packages`

Installed version of medfate should be ver 2.9 or higher.

install.packages("medfate")

If the version at CRAN is older, the package should be installed from GitHub via remotes::install_github():

remotes::install_github("emf-creaf/medfate")

Package medfateutils is required for the species parameterization process, as it includes several functions that facilitate parsing data sources into parameter values. Package medfateutils is installed only from GitHub:

remotes::install_github("emf-creaf/medfateutils")

Once we have medfate and medfateutils, we load them and other common packages that we will employ in this vignette:

library(medfate)
library(medfateutils)
## Warning: replacing previous import 'dplyr::filter' by 'stats::filter' when
## loading 'medfateutils'

Source data paths

Befores starting, we define file paths (in my computer) to access source data for parameter filling. Source data includes forest inventory (i.e. IFN) data as well as plant trait and allometric data bases:

IFN_path = "/home/miquel/OneDrive/EMF_datasets/ForestInventories/IFN/"

Load IFN taxon codes

Model simulations will normally entail a lower biological resolution of target entities than used in forest inventory data, because the finer the biological resolution the large the number of missing parameter values. Therefore, it will be usual to consider together entities that are treated as distinct in the forest inventory.

In our case, we begin by loading shrub and tree species codes used in the second, third, and fourth editions of IFN, i.e. IFN2, IFN3 and IFN4:

IFN23_species_data <- read.csv(paste0(IFN_path,"Sources/SpeciesCodesIFN23.txt"), 
                             sep="\t")
IFN23_species_data<-IFN23_species_data[,c(1,2)]
IFN23_species_data$IFNCODE<-as.character(IFN23_species_data$IFNCODE)

IFN4_shrub_species_data <- read.csv(paste0(IFN_path,"Sources/shrubcodesifn4.txt"), 
                             sep="\t")
IFN4_shrub_species_data$IFNCODE<-as.character(IFN4_shrub_species_data$IFNCODE)
IFN4_tree_species_data <- read.csv(paste0(IFN_path,"Sources/treecodesifn4.txt"), 
                                    sep="\t")
IFN4_tree_species_data$IFNCODE<-as.character(IFN4_tree_species_data$IFNCODE)
IFN4_tree_species_data<-IFN4_tree_species_data[,c(1,2)]

Merge the two code data sets by adding to the codes of IFN2-3 those species codes that were new in IFN4:

newShrubs <- !(IFN4_shrub_species_data$IFNCODE %in% IFN23_species_data$IFNCODE)
newTrees <- !(IFN4_tree_species_data$IFNCODE %in% IFN23_species_data$IFNCODE)
IFN_species_data <- dplyr::bind_rows(IFN23_species_data, 
                              IFN4_shrub_species_data[newShrubs, ], 
                              IFN4_tree_species_data[newTrees,])
IFN_species_data <- IFN_species_data[order(as.numeric(IFN_species_data$IFNCODE)),]

Check uniqueness of codes:

length(unique(IFN_species_data$IFNCODE)) == nrow(IFN_species_data)
## [1] TRUE

The final table of species names and codes has 469 rows and looks like:

head(IFN_species_data)
##   IFNCODE               IFNNAME
## 1       1 Heberdenia bahamensis
## 2       2    Amelanchier ovalis
## 3       3        Frangula alnus
## 4       4     Rhamnus alaternus
## 5       5    Euonymus europaeus
## 6       6       Myrtus communis

So far, we used the word species for IFN biological entities, but in fact not all IFN entities are binomial species. In some cases, subspecies are recorded, while in others identification is at genus level or even uses non-scientific names. Hence, the set of entities needs to be revised and we illustrate the process in the following two sections.

Define IFN codes to exclude

We need to manually define a set of entities (IFN codes) to be excluded because they have low taxonomic information, refer to habitat descriptions or to undesired growth forms (e.g. vines):

codesOut <- c("19", # Otras coniferas 
              "10", # Sin asignar
              "20", # Pinos
              "29", # Otros pinos
              "30",  #Mezcla de coniferas
              "40", #Quercus
              "49", #Otros quercus
              "50", #Mezcla de <e1>rboles de ribera
              "59", #Otros <e1>rboles rip<ed>colas
              "70", #Mezcla de frondosas de gran porte
              "80", #Laurisilva
              "89", #Otras laurisilvas
              "90", #Mezcla de peque<f1>as frondosas
              "99", #Otras frondosas
              "1500", # Cultivo en mosaico
              "8000", # Matorral en mosaico
              "9000", #Herbazal en mosaico
              "3400", #Prado en mosaico
              "3500", #Pastizal-Matorral en mosaico
              "103", #Otras papilionoideas altas
              "104" #Otras papilionoideas bajas
              )

We remove taxa from the IFN taxonomic definition data frame:

IFN_species_data <- IFN_species_data[!(IFN_species_data$IFNCODE %in% codesOut), ]

so that we are left with 448 taxa.

Define taxonomic entities to merge into groups

As mentioned above, simulations will normally require defining groups of entities to be treated together in medfate. In our case, we need to define some genus-level groups because the forest inventory records do not always have identifications at species-level resolution:

genus_level <- c("Acacia spp.:7/207/307",
                 "Adenocarpus spp.:1163/2163/2103/3163/10103",
                 "Anagyris spp.:175/1175",
                 "Atriplex spp.:133",
                 "Artemisia spp.:126/159/1159/3159",
                 "Asparagus spp.:138/1138/2138",
                 "Astragalus spp.:6104",
                 "Betula spp.:73/273/373",
                 "Bupleurum spp.:124/1124/2124/4124",
                 "Calicotome spp.:2104/2105/9072/3104",
                 "Cedrus spp.:17/217/317/917",
                 "Corema spp.:172/1172",
                 "Chamaerops humilis:369/3690",
                 "Clematis spp.:132/1132/2132",
                 "Crataegus spp.:15/215/315/415/515",
                 "Coronilla spp.:152/1152/3152/5104",
                 "Cotoneaster spp.:118",
                 "Cupressus spp.:36/236/336/436/936",
                 "Daphne spp.:110/1110/2110/3110",
                 "Dorycnium spp.:154/7104/1154",
                 "Echium spp..:161",
                 "Ephedra spp.:173/1173",
                 "Erinacea spp.:1104/1166",
                 "Eucalyptus spp.:60/61/62/63/64/264/364/464",
                 "Euphorbia spp.:162/1162/2162/3162",
                 "Fraxinus spp.:55/255/355/455/955",
                 "Genista spp.:177/1177/155/1155/1255/1355/1455/1555/1755/1156/1655/2155/2156/3155/4155/6155/7155/8155/9075/9155/10155/11155/12155/13155/14155",
                 "Genistella spp.:9104",
                 "Halimium spp.:117/1117/2117/3117/4117/5117/6117",
                 "Helianthemum spp.:142",
                 "Helichrysum spp.:128/1128/2128",
                 "Larix spp.:35/235/335/435",
                 "Lavandula spp.:109/1109/2109/3109/4109",
                 "Lonicera spp.:144/1144/2144/3144/4144/5144/9012",
                 "Ilex spp.:65/82/282",
                 "Juglans spp.:75/275/975",
                 "Laurus spp.:94/294",
                 "Maytenus spp.:158/1158",
                 "Morus spp.:399/499/599",
                 "Ononis spp.:156/8104",
                 "Osyris spp.:135/1135/2135",
                 "Platanus spp.:79/279",
                 "Populus spp.:51/52/58/258",
                 "Phlomis spp.:171/1171/2171",
                 "Phoenix spp.:69/269/469",
                 "Prunus spp.:95/295/395/495/595/1095/1195/2950/148",
                 "Pyrus spp.:16",
                 "Retama spp.:4103/1165/2165",
                 "Rhamnus spp.:4/122/1122/2122/3122/4122/389/5122/6122",
                 "Rhododendron spp.:108/1108/2108",
                 "Ribes spp.:131/1131/2131",
                 "Rosa spp.:119",
                 "Rubus spp.:121/1121/2121/3121",
                 "Ruscus spp.:130/1130",
                 "Salix spp.:57/257/357/457/557/657/757/857/858/957",
                 "Sambucus spp.:97/197/297/997/2970",
                 "Santolina spp.:127/1127/2127",
                 "Sorbus spp.:78/278/378/478/578/678/778",
                 "Spartium spp.:3103/9103",
                 "Spiraea spp.:134/1134",
                 "Tamarix spp.:53/253",
                 "Teline spp.:165/9077/9078/9202/9914",
                 "Teucrium spp.:179/1179",
                 "Tilia spp.:77/277/377",
                 "Thymelaea spp.:151",
                 "Thuja spp.:319",
                 "Thymus spp.:129/1129/2129/3129/4129/5129",
                 "Ulex spp.:157/176/1103/6103/1164/3164", #Merges Stauracanthus
                 "Ulmus spp.:56/256/356/456/956",
                 "Vaccinium spp.:137/1137",
                 "Vella spp.:170/1170",
                 "Viburnum spp.:115/1115/4115/3115/2115"
                 )

Groups were manually defined as strings where ‘:’ was used to separate the group name from the set of codes forming the group, which were separated using ‘/’. We also define groups of taxa at species level, where different synonyms are merged, different codes have been used for the same species, or to merge sub-specific records:

assimilated_species<-c("Acer campestre:76/776/976",
                       "Amelanchier ovalis:2/200",
                       "Buxus sempervirens:91/291/2910/9071/9100",
                       "Cistus albidus:101/3101",
                       "Cistus psilosepalus:2111/11101",
                       "Cornus sanguinea:9/900",
                       "Cytisus fontanesii:9074",
                       "Cytisus scoparius:4104/1167/5103/8103",
                       "Cytisus commutatus:9011/9201/9481",
                       "Cytisus oromediterraneus:5155/4167",
                       "Erica scoparia:283/6102",
                       "Erica arborea:83/102/1102",
                       "Euonymus europaeus:5/500",
                       "Frangula alnus:3/300",
                       "Juniperus communis:37/937/3700",
                       "Juniperus phoenicea:39/238/239/1139",
                       "Medicago arborea:145/9076",
                       "Myrtus communis:6/600",
                       "Myrica faya:81/281",
                       "Pistacia terebinthus:93/9300",
                       "Quercus ilex:45/245",
                       "Quercus faginea:44/344",
                       "Quercus suber:46/646/746/846/946",
                       "Salvia rosmarinus:114/1114") 

We now build a data frame with group names and codes, by merging the information of these two groups of taxa. We also separate group names from the set of codes defining the group into columns of a data frame:

groups_df <- data.frame("Groups" = c(genus_level,
                                     assimilated_species)) |>
  tidyr::separate("Groups", into=c("group_names", "group_codes"), sep=":")
head(groups_df)
##        group_names               group_codes
## 1      Acacia spp.                 7/207/307
## 2 Adenocarpus spp. 1163/2163/2103/3163/10103
## 3    Anagyris spp.                  175/1175
## 4    Atriplex spp.                       133
## 5   Artemisia spp.         126/159/1159/3159
## 6   Asparagus spp.             138/1138/2138

We now filter out from the species data frame those that are already included as part of species groups

in_groups = unlist(strsplit(groups_df$group_codes, split="/"))
sel = !(IFN_species_data$IFNCODE %in% in_groups)
cat(paste0(sum(!sel), " codes found in groups.\n"))
## 327 codes found in groups.
IFN_species_unique <- IFN_species_data[sel, ]

Create species mapping data frame

Once we have IFN species names and codes, as well as the definition of the IFN biological entities to merge, we can create the mapping data frame using:

IFN_species_mapping <- data.frame(Name = c(IFN_species_unique$IFNNAME, groups_df$group_names),
                                  Codes = c(IFN_species_unique$IFNCODE, groups_df$group_codes))
IFN_species_mapping <- IFN_species_mapping[order(IFN_species_mapping$Name),, drop = FALSE]

The resulting data frame has 217 entities and looks like:

head(IFN_species_mapping)
##                    Name      Codes
## 16           Abies alba         31
## 17        Abies pinsapo         32
## 122         Acacia spp.  7/207/307
## 194      Acer campestre 76/776/976
## 81  Acer monspessulanum        276
## 87         Acer negundo        376