After applying the divide_plot()
function, this function summarises with any defined function the desired tree metric by sub-plot and displays the plot representation.
Arguments
- subplots
output of the
divide_plot()
function- value
a character indicating the column in subplots$tree_data to be summarised (or character vector to summarise several metrics at once)
- draw_plot
a logical indicating whether the plot design should be displayed
- per_ha
a logical indicating whether the metric summary should be per hectare (or, if summarising several metrics at once: a logical vector corresponding to each metric (see examples))
- fun
the function to be applied (or, if summarising several metrics at once: a list of functions named according to each metric (see examples))
- ...
optional arguments to fun
Value
a list containing the following elements :
tree_summary
: a summary of the metric per subplotpolygon
: an sf object : simple feature collection of the subplot's polygonplot_design
: a ggplot object (or a list of ggplot objects) that can easily be modified
Examples
# One plot with repeated measurements of each corner
data("NouraguesPlot201")
data("NouraguesTrees")
check_plot201 <- check_plot_coord(
corner_data = NouraguesPlot201,
proj_coord = c("Xutm","Yutm"), rel_coord = c("Xfield","Yfield"),
trust_GPS_corners = TRUE, draw_plot = FALSE)
subplots_201 <- suppressWarnings(
divide_plot(
corner_data = check_plot201$corner_coord,
rel_coord = c("x_rel","y_rel"), proj_coord = c("x_proj","y_proj"),
grid_size = 50,
tree_data = NouraguesTrees[NouraguesTrees$Plot == 201,],
tree_coords = c("Xfield","Yfield")))
# Sum summary (by default) of diameter
subplots_201_sum <- subplot_summary(subplots_201 , value = "D", draw_plot = FALSE)
subplots_201_sum$tree_summary
#> subplot_ID D_sum_per_ha
#> subplot_0_0 subplot_0_0 10656.19
#> subplot_0_1 subplot_0_1 10708.82
#> subplot_1_0 subplot_1_0 12103.82
#> subplot_1_1 subplot_1_1 12972.33
subplots_201_sum$polygon
#> Simple feature collection with 4 features and 2 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 312956.9 ymin: 451582.6 xmax: 313100.5 ymax: 451723.2
#> CRS: NA
#> subplot_ID D_sum_per_ha sf_subplot_polygon
#> subplot_0_0 subplot_0_0 10656.19 POLYGON ((313005.7 451723.2...
#> subplot_0_1 subplot_0_1 10708.82 POLYGON ((313053.1 451694.5...
#> subplot_1_0 subplot_1_0 12103.82 POLYGON ((312981.3 451676.7...
#> subplot_1_1 subplot_1_1 12972.33 POLYGON ((313028.4 451650.5...
# \donttest{
subplots_201_sum$plot_design
# }
# 9th quantile summary (for example) of diameter
subplots_201_quant <- subplot_summary(subplots_201 , value = "D", draw_plot = FALSE,
fun = quantile, probs=0.9)
# Dealing with multiple plots
if (FALSE) { # \dontrun{
data("NouraguesCoords")
nouragues_subplots <- suppressWarnings(
divide_plot(
corner_data = NouraguesCoords,
rel_coord = c("Xfield","Yfield"), proj_coord = c("Xutm","Yutm"),
corner_plot_ID = "Plot",
grid_size = 50,
tree_data = NouraguesTrees, tree_coords = c("Xfield","Yfield"),
tree_plot_ID = "Plot"))
# Sum summary (by default)
nouragues_sum <- subplot_summary(nouragues_subplots , value = "D", draw_plot = FALSE)
nouragues_sum$tree_summary
nouragues_sum$plot_design
} # }
if (FALSE) { # \dontrun{
data("NouraguesCoords")
nouragues_subplots <- suppressWarnings(
divide_plot(
corner_data = NouraguesCoords,
rel_coord = c("Xfield","Yfield"), proj_coord = c("Xutm","Yutm"),
corner_plot_ID = "Plot",
grid_size = 50,
tree_data = NouraguesTrees, tree_coords = c("Xfield","Yfield"),
tree_plot_ID = "Plot"))
# Sum summary (by default)
nouragues_mult <- subplot_summary(nouragues_subplots ,
value = c("D","D","x_rel"),
fun = list(D=sum,D=mean,x_rel=mean),
per_ha = c(T,F,F),
draw_plot = FALSE)
nouragues_mult$tree_summary
nouragues_mult$plot_design$`201`[[1]]
nouragues_mult$plot_design$`201`[[2]]
nouragues_mult$plot_design$`201`[[3]]
} # }