strat_kmeans {sgsR} | R Documentation |
k-means stratification
Description
Stratify metrics raster using kmeans
algorithm
Usage
strat_kmeans(
mraster,
nStrata,
iter = 500,
algorithm = "Lloyd",
center = TRUE,
scale = TRUE,
plot = FALSE,
details = FALSE,
filename = NULL,
overwrite = FALSE,
...
)
Arguments
mraster |
spatRaster. ALS metrics raster. |
nStrata |
Numeric. Number of desired strata. |
iter |
Numeric. The maximum number of iterations allowed. |
algorithm |
Character. |
center |
Logical. Value indicating whether the variables should be shifted to be zero centered. |
scale |
Logical. Value indicating whether the variables should be scaled to have unit variance. |
plot |
Logical. Plots output strata raster and visualized strata with boundary dividers. |
details |
Logical. If |
filename |
Character. Path to write stratified raster to disc. |
overwrite |
Logical. Specify whether |
... |
Additional arguments to be passed to |
Value
output stratification spatRaster
, or a list when details = TRUE
.
Author(s)
Tristan R.H. Goodbody
See Also
Other stratify functions:
strat_breaks()
,
strat_map()
,
strat_poly()
,
strat_quantiles()
Examples
#--- Load raster and access files ---#
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)
#--- perform stratification using k-means ---#
kmeans <- strat_kmeans(
mraster = mr,
nStrata = 5
)
kmeans <- strat_kmeans(
mraster = mr,
nStrata = 5,
iter = 1000,
algorithm = "MacQueen",
details = TRUE
)