# Load species parameters
data(SpParamsMED)
# Create an empty forest object
f <- emptyforest()
# (1) Mapping tree data
# Load Poblet tree data
data(poblet_trees)
# Subset control plot
x <- subset(poblet_trees, Plot.Code=="POBL_CTL")
# Estimate sampled area (15-m radius plot)
sampled_area <- pi*15^2
# Define mapping
mapping_x <- c("Species.name" = "Species", "DBH" = "Diameter.cm")
# Map tree data for plot 'POBL_CTL'
f$treeData <- forest_mapTreeTable(x,
mapping_x = mapping_x, SpParams = SpParamsMED,
plot_size_x = sampled_area)
# (2) Mapping shrub individual data
#
# Create the individual shrub data frame
species <- c("Erica arborea","Cistus albidus", "Erica arborea", "Cistus albidus", "Cistus albidus")
H <- c(200,50,100,40,30)
D1 <- c(140,40,100, 35,30)
D2 <- D1
y <- data.frame(species, H, D1, D2)
# Define mapping (D1 and D2 map to variables with the same name)
mapping_y <- c("Species.name"= "species", "Height" ="H", "D1", "D2")
# Map individual shrub data to cover data (here each individual becomes a cohort)
# assuming that the sampled area was 4 m2
f$shrubData <- forest_mapShrubTable(y,
mapping_y = mapping_y, SpParams = SpParamsMED,
plot_size_y = 4)
# (3) Print forest attributes
summary(f, SpParamsMED)
# (4) Forest initialization in a single step
f <- forest_mapWoodyTables(x, y,
mapping_x = mapping_x, mapping_y = mapping_y,
SpParams = SpParamsMED,
plot_size_x = sampled_area, plot_size_y = 4)
summary(f, SpParamsMED)
Run the code above in your browser using DataLab