strucDivNest {StrucDiv} | R Documentation |
Quantify Spatial Structural Diversity Across Scales in an Arbitrary Raster Layer
Description
This is a wrapper function that returns a 'spatial structural diversity map'
as a raster layer. Spatial refers to horizontal, i.e. spatially explicit, and
'spatial structural diversity' will hereafter be used synonymous to 'structural diversity'.
Pixels are considered as pairs in user-specified distances and angles.
Angles include horizontal and vertical direction, and the diagonals at 45° and 135°.
The direction-invariant version considers all angles.
Spatial structural diversity is quantified based on the probabilities that pixel values
are arranged in the specified way (distance and angle). The strucDiv
function employs empirical probabilities of pixel value co-occurrence.
The strucDivNest
function combines information from two different scales with an empirical Bayesian approach and a Beta-Binomial model.
Two scales are nested inside each other - a larger, outer scale and a smaller, inner scale.
Three different nesting schemes are available, whereby the inner scale is always a moving window.
The outer scale can either be another mowing window, a block, or the domain (i.e. the input raster).
The outer scale is used as prior information for data on the inner scale, and structural diversity is quantified based on
posterior probabilities of pixel value co-occurrences.
In the Beta-Binomial model both the prior and the posterior follow a beta distribution, and the likelihood follows a conditional
binomial distribution.
Posterior probabilities are estimated with mean estimates.
The final map is called a '(spatial) structural diversity map' and is returned as a raster layer.
The output map represents structural diversity, quantified across different spatial scales, which are defined
by the outer scale and the inner scale.
Usage
strucDivNest(
x,
wslI = NULL,
wslO = NULL,
dimB = FALSE,
oLap = NULL,
priorB = FALSE,
domain = FALSE,
dist = 1,
angle = "all",
rank = FALSE,
fun,
delta = 0,
na.handling = na.pass,
padValue = NA,
aroundTheGlobe = FALSE,
ncores = 1,
verbose = TRUE,
filename = "",
...
)
Arguments
x |
raster layer. Input raster layer for which horizontal structural diversity should be calculated. |
wslI |
uneven integer. The window side length of the inner scale,
|
wslO |
uneven integer. The window side length of the outer scale,
|
dimB |
a vector of length 2 or logical. This defines the block size (number of rows, number of columns).
The domain (i.e. the input raster) is divided into equal size, overlapping blocks.
Each block provides prior information for the inner window, which moves inside each block.
Structural diversity is quantified in each block.
Blocks are merged together in a spatially weighted manner, using linear weights.
Defaults to |
oLap |
integer. This defines the size of overlap between the blocks. The overlap must
be at least |
priorB |
logical. Should blocks be used for prior information?
If |
domain |
logical. Should the domain (i.e. the input raster) be used for prior information?
If |
dist |
integer. The distance between two pixels that should be considered as a pair,
defaults to |
angle |
string. The angle on which pixels should be considered as pairs.
Takes 5 options: |
rank |
logical. Should pixel values be replaced with ranks in each GLCM? Defaults to |
fun |
function, the structural diversity metric. Takes one of the following: |
delta |
numeric, takes three options: |
na.handling |
|
padValue |
numeric or |
aroundTheGlobe |
logical. If the input raster goes around the whole globe,
set |
ncores |
integer. The number of cores the computation will be parallelized on. Parallelization is only available when blocks are used. i.e. dimB must be specified. Parallelization can be used independent of whether blocks are used as priors or not. |
verbose |
logical. If |
filename |
character. If the output raster should be written to a file, define file name (optional). |
... |
possible further arguments. |
Details
The memory requirement of the function is determined
by raster::canProcessInMemory()
.
If the raster file cannot be processed in memory, its size needs to be reduced before strucDivNest
can be used.
Value
The output is a (spatial) structural diversity map, returned as a raster layer.
If the outer scale is a moving window or the domain, then the output raster has the same dimensions as the input raster.
If the outer scale is a block, then the output raster may be smaller than the input raster
because if there are edges that do not fit inside the blocks, they are cut off.
When na.handling = na.pass
, then the output map will have an NA-edge of 0.5*(wslO
-1),
and it will contain more missing values than the input raster.
The output represents spatial structural diversity quantified across different spatial scale, which are defined by the
size of the inner and the outer scale.
Examples
## Not run:
# Construct a small raster file containing realizations of normal random variables:
a <- raster::raster(matrix(rnorm(400), 20, 20))
raster::plot(a)
# Calculate structural diversity entropy with delta = 2, double moving window scheme
sde_1 <- strucDivNest(a, wslI = 3, wslO = 5, angle = "horizontal", fun = entropy, delta = 2)
raster::plot(sde_1)
# Calculate structural diversity entropy with delta = 1, block nesting scheme
b <- raster::raster(matrix(rnorm(2500), 50, 50))
raster::plot(b)
sde_b <- strucDivNest(b, wslI = 3, dimB = c(10, 10), oLap = 4, priorB = TRUE, fun = entropy,
delta = 1)
raster::plot(sde_b)
# Calculate entropy on simulated random patch, domain nesting scheme
patch <- raster::raster(patch)
entropy_patch <- strucDivNest(patch, wslI = 5, domain = TRUE, angle = "vertical", fun = entropy)
raster::plot(entropy_patch)
## End(Not run)