Description Usage Arguments Details Value See Also Examples

Summarization tool for calculating tree counts and statistics within various spatial units.

1 2 3 4 5 6 7 |

`trees` |
SpatialPointsDataFrame or SpatialPolygonsDataFrame. The locations of a
set of trees, typically detected from a canopy height model using |

`areas` |
SpatialPolygonsDataFrame. An optional set of polygons corresponding to areas of interest. Tree counts and statistics will be returned for each area. |

`grid` |
RasterLayer (see raster) or numeric. An alternative to the |

`variables` |
character. The names of tree attribute variables (stored in the |

`statFuns` |
list. A named list of custom functions that are used to compute tree attribute statistics. If none are provided, default statistics are mean, median, standard deviation, minimum and maximum. Note that each element of the list should have a name that describes the statistics generated by the function. See below for details on defining custom functions. |

Input trees can either be point locations (SpatialPointsDataFrame) or crown outlines (SpatialPolygonsDataFrame). If crown outlines (or other polygons) are inputted, they will be partitioned between spatial units according to their geographic centroids.

In addition to tree counts, statistics for the trees' attributes can also be
generated. These attributes should be defined within the `@data`

slot of the `input`

. Only
numeric variables are accepted.

By default, the statistics generated for each attribute will be its mean, median, standard deviation,
minimum and maximum. However, custom functions can also be used with the `statFuns`

argument.
This should be a named list of functions, wherein each list element is given a name to represent the
statistic computed by the function.

For example: `list(qunt98 = function(x, ...) quantile(x, c(.98), na.rm = TRUE))`

Furthermore, custom functions should:

Be able to accept numeric vectors.

Be able to handle NA values.

Have an ellipsis (three dots) in their arguments:

`function(x, ...)`

Return a single numeric value.

Tree count and, if any `variables`

are supplied, tree attribute statistics. If no
`areas`

or `grid`

is supplied, the tree count and statistics are computed for the entire
`trees`

dataset, and returned as a 'data.frame' object. If `areas`

are defined, an
identical SpatialPolygonsDataFrame will be returned, with all computed statistics appended
to the object's `@data`

slot. If a `grid`

is defined, tree count will be returned as a RasterLayer,
with cell values equal to the number of trees in each cell. If a `grid`

and `variables`

are defined,
a RasterBrick (see brick) will be returned instead, with tree count and attribute statistics
stored as stacked layers.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# Load sample data
library(ForestTools)
library(sp)
data("kootenayTrees", "kootenayBlocks", "kootenayCrowns")
# Get total tree count
sp_summarise(kootenayTrees)
# Get total tree count, tree height and crown area statistics
sp_summarise(kootenayCrowns, variables = c("height", "crownArea"))
# Get tree count, height statistics for specific areas of interest
areaStats <- sp_summarise(kootenayTrees, areas = kootenayBlocks, variables = "height")
# Plot according to tree count
plot(areaStats, col = heat.colors(3)[order(areaStats$TreeCount)])
# Get tree count and height statistics for a 20 x 20 m spatial grid
gridStats <- sp_summarise(kootenayTrees, grid = 20, variables = "height")
# Plot gridded tree count and statistics
plot(gridStats$TreeCount)
plot(gridStats$heightMax)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.