Title: | Tools for Analyzing Remote Sensing Forest Data |
---|---|
Description: | Tools for analyzing remote sensing forest data, including functions for detecting treetops from canopy models, outlining tree crowns, and calculating textural metrics. |
Authors: | Andrew Plowright [aut, cre], Jean-Romain Roussel [ctb] (Contributed to segment-based GLCM segmentation) |
Maintainer: | Andrew Plowright <[email protected]> |
License: | GPL-3 |
Version: | 1.0.3 |
Built: | 2025-03-08 06:02:47 UTC |
Source: | https://github.com/andrew-plowright/foresttools |
Generate textural metrics using Grey-Level Co-Occurrence Matrices (GLCM). Can be applied to an entire or image or, if a coterminous raster of segments is provided, GLCM can be calculated for each segment.
glcm(image, segs = NULL, n_grey = 32, angle = c(0, 1), discretize_range = NULL)
glcm(image, segs = NULL, n_grey = 32, angle = c(0, 1), discretize_range = NULL)
image |
SpatRaster. A single-band raster layer from which texture is measured |
segs |
SpatRaster. A segmented raster. Cell values should be equal to segment numbers. If |
n_grey |
integer. Number of grey levels into which the image will be discretized |
angle |
integer. Angle at which GLCM will be calculated. Ex.: 'c(0,1)' |
discretize_range |
numeric. Vector of two values indicating the minimum and maximum input values for discretizing the image. This can be useful when processing tiles of a larger image, for which you may want to impose a consistent value range. |
data.frame
Parmar, C., Velazquez, E.R., Leijenaar, R., Jermoumi, M., Carvalho, S., Mak, R.H., Mitra, S., Shankar, B.U., Kikinis, R., Haibe-Kains, B. and Lambin, P. (2014). Robust radiomics feature quantification using semiautomatic volumetric segmentation. PloS one, 9(7)
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) image <- rast(kootenayOrtho)[[1]] # Generate raster segments segs <- mcws(kootenayTrees, chm, minHeight = 0.2, format = "raster") # Get textural metrics for ortho's red band tex <- glcm(image, segs) ## End(Not run)
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) image <- rast(kootenayOrtho)[[1]] # Generate raster segments segs <- mcws(kootenayTrees, chm, minHeight = 0.2, format = "raster") # Get textural metrics for ortho's red band tex <- glcm(image, segs) ## End(Not run)
Boundaries of cut blocks within a 1.5 hectare section of forest in the Kootenay mountains, in British Columbia, Canada. Each block contains trees of different levels of maturity. Overlaps with kootenayTrees, kootenayCrowns, kootenayOrtho and kootenayCHM.
kootenayBlocks
kootenayBlocks
Simple polygon feature collection with the following attributes:
numerical identifier for each block
length of polygon on meters
area of polygon in square meters
kootenayTrees kootenayCHM kootenayCrowns kootenayOrtho
A canopy height model of a 1.5 hectare section of forest in the Kootenay mountains, in British Columbia, Canada.
kootenayCHM
kootenayCHM
PackedSpatRaster object
Cell values are equal to canopy height above ground (in meters)
Data acquired from a photogrammetric drone survey performed by Spire Aerobotics on June 16th, 2016.
kootenayTrees kootenayBlocks kootenayCrowns kootenayOrtho
Outlines of tree crowns corresponding to the kootenayTrees treetops. Generated using mcws.
kootenayCrowns
kootenayCrowns
Simple polygon feature collection with the following attributes:
height of the tree's apex, in meters above ground. Inherited from kootenayTrees.
radius of the moving window at the treetop's location. Inherited from kootenayTrees.
area of crown outline in square meters
kootenayTrees kootenayCHM kootenayBlocks kootenayOrtho
An orthomosaic of a 1.5 hectare section of forest in the Kootenay mountains, in British Columbia, Canada.
kootenayOrtho
kootenayOrtho
PackedSpatRaster object
Cell values are equal to canopy height above ground (in meters)
Data acquired from a photogrammetric drone survey performed by Spire Aerobotics on June 16th, 2016.
kootenayTrees kootenayBlocks kootenayCrowns kootenayCHM
Dominant trees from a 1.5 hectare section of forest in the Kootenay mountains, in
British Columbia, Canada. Trees were detected by applying the vwf
function to the kootenayCHM raster dataset. Only trees over 2 m above ground
were detected.
kootenayTrees
kootenayTrees
Simple point feature collection with the following attributes:
height of the tree's apex, in meters above ground
radius of the moving window (see vwf
) at
the treetop's location
kootenayCHM kootenayBlocks kootenayCrowns kootenayOrtho
This function implements the watershed function to segment (i.e.: outline) crowns from a CHM (canopy height model). Segmentation is guided by the point locations of treetops, typically detected using the vwf function. See Meyer & Beucher (1990) for details on watershed segmentation.
mcws( treetops, CHM, minHeight = 0, format = "raster", OSGeoPath = NULL, IDfield = "treeID" )
mcws( treetops, CHM, minHeight = 0, format = "raster", OSGeoPath = NULL, IDfield = "treeID" )
treetops |
sf. The point locations of treetops in |
CHM |
SpatRaster. Canopy height model in |
minHeight |
numeric. The minimum height value for a |
format |
string. Format of the function's output. Can be set to either 'raster' or 'polygons'. |
OSGeoPath |
character. Obsolete. Will be removed next version |
IDfield |
character. Name of the field for storing the unique tree identifier |
Crown segments are returned as either a SpatRaster
or a sf
(Simple Feature) class object,
as defined using the format
argument. For many analytic purposes, it is preferable to have
crown outlines as polygons. However, polygonal crown maps take up significantly more disk space, and take
longer to process. It is advisable to run this function using a raster output first to review
results and adjust parameters.
NOTE: when setting format
to 'polygons', orphaned segments (i.e.: outlines without an associated treetop) will be removed.
This will NOT occur using 'raster' format. This issue will be resolved eventually but requires the watershed function to
be rewritten.
Depending on the setting for format
, this function will return a map of outlined
crowns as either a SpatRaster
class object, in which distinct crowns are given a unique cell value, or a sf
class object, in which each crown
is represented by a polygon.
Meyer, F., & Beucher, S. (1990). Morphological segmentation. Journal of visual communication and image representation, 1(1), 21-46.
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) # Use variable window filter to detect treetops ttops <- vwf(chm, winFun = function(x){x * 0.06 + 0.5}, minHeight = 2) # Segment tree crowns segs <- mcws(ttops, chm, minHeight = 1) ## End(Not run)
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) # Use variable window filter to detect treetops ttops <- vwf(chm, winFun = function(x){x * 0.06 + 0.5}, minHeight = 2) # Segment tree crowns segs <- mcws(ttops, chm, minHeight = 1) ## End(Not run)
Boundaries of cut blocks within a 125 hectare section of forest in the Quesnel Timber Supply Area, in British Columbia, Canada. Each block contains trees of different levels of maturity. Overlaps with quesnelTrees and quesnelCHM.
quesnelBlocks
quesnelBlocks
Simple polygon feature collection with the following attributes:
numerical identifier for each block
length of polygon on meters
area of polygon in square meters
A canopy height model of a 125 hectare section of forest in the Quesnel Timber Supply Area, in British Columbia, Canada.
quesnelCHM
quesnelCHM
PackedSpatRaster object
Cell values are equal to canopy height above ground (in meters)
Data acquired from a photogrammetric drone survey performed by Spire Aerobotics on September 15th, 2016.
Dominant trees from a 125 hectare section of forest in the Quesnel Timber Supply Area, in
British Columbia, Canada. Trees were detected by applying the vwf
function to the quesnelCHM raster dataset. Only trees over 2 m above ground
were detected.
quesnelTrees
quesnelTrees
Simple point feature collection with the following attributes:
height of the tree's apex, in meters above ground
radius of the moving window (see vwf
) at
the treetop's location
Implements the variable window filter algorithm (Popescu & Wynne, 2004) for detecting treetops from a canopy height model.
vwf( CHM, winFun, minHeight = NULL, warnings = TRUE, minWinNeib = "queen", IDfield = "treeID", resolution_round = 5 )
vwf( CHM, winFun, minHeight = NULL, warnings = TRUE, minWinNeib = "queen", IDfield = "treeID", resolution_round = 5 )
CHM |
SpatRaster. Canopy height model in SpatRaster format. |
winFun |
function. The function that determines the size of the window at any given location on the
canopy. It should take the value of a given |
minHeight |
numeric. The minimum height value for a |
warnings |
logical. If set to FALSE, this function will not emit warnings related to inputs. |
minWinNeib |
character. Define whether the smallest possible search window (3x3) should use a |
IDfield |
character. Name of field for unique tree identifier |
resolution_round |
integer. The raster resolution is used to compute the dimensions of the search windows. By default, this resolution is rounded to 5 decimal places. The number of decimal places can be changed using this parameter. Increasing this value is also a work-around for errors relating to non-square cell sizes. |
This function uses the resolution of the raster to figure out how many cells the window needs to cover. This means that the raster value (representing height above ground) and the map unit (represented by the raster's resolution), need to be in the _same unit_. This can cause issues if the raster is in lat/lon, whereby its resolution is in decimal degrees.
Simple feature collection of POINT type. The point locations of detected treetops. The object contains two fields in its
data table: height is the height of the tree, as extracted from the CHM
, and winRadius is the radius
of the search window when the treetop was detected. Note that winRadius does not necessarily correspond to the radius
of the tree's crown.
Popescu, S. C., & Wynne, R. H. (2004). Seeing the trees in the forest. Photogrammetric Engineering & Remote Sensing, 70(5), 589-604.
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) # Set function for determining variable window radius winFunction <- function(x){x * 0.06 + 0.5} # Set minimum tree height (treetops below this height will not be detected) minHgt <- 2 # Detect treetops in demo canopy height model ttops <- vwf(chm, winFunction, minHgt) ## End(Not run)
## Not run: library(terra) library(ForestTools) chm <- rast(kootenayCHM) # Set function for determining variable window radius winFunction <- function(x){x * 0.06 + 0.5} # Set minimum tree height (treetops below this height will not be detected) minHgt <- 2 # Detect treetops in demo canopy height model ttops <- vwf(chm, winFunction, minHgt) ## End(Not run)