Spatial Summarization
Summarization tool for calculating tree counts and statistics within various spatial units.
sp_summarise( trees, areas = NULL, grid = NULL, variables = NULL, statFuns = NULL )
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.
# 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.