strat_quantiles {sgsR}R Documentation

Quantiles stratification

Description

Stratify metric raster using metric quantiles.

Usage

strat_quantiles(
  mraster,
  nStrata,
  map = FALSE,
  plot = FALSE,
  details = FALSE,
  filename = NULL,
  overwrite = FALSE
)

Arguments

mraster

spatRaster. ALS metrics raster.

nStrata

Numeric. A positive integer representing the number of desired classes or a numeric vector of probabilities with values between 0-1. If mraster has multiple layers, nStrata must be a list with an equal number of objects.

map

Logical. Map individual stratified layers to a combined stratification. Will output a multi-layer SpatRaster with individual stratifications for each mraster layer and an additional mapped stratification named "strata".

plot

Logical. Plots output strata raster and visualized strata with boundary dividers.

details

Logical. If FALSE (default) output is only stratification raster. If TRUE return a list where $details is additional stratification information and $raster is the output stratification spatRaster.

filename

Character. Path to write stratified raster to disc.

overwrite

Logical. Specify whether filename should be overwritten on disc.

Value

Returns an output stratification spatRaster or a list when details = TRUE.

When a list is returned:

  1. details lookUp table for stratification(s).

  2. raster is a stratified spatRaster based on quantiles

  3. plot is a ggplot histogram / scatter plot object (depends on whether metric2 was supplied). Histogram shows distribution and break points.

Author(s)

Tristan R.H. Goodbody

See Also

Other stratify functions: strat_breaks(), strat_kmeans(), strat_map(), strat_poly()

Examples

#--- Load raster and existing plots---#
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)

strat_quantiles(
  mraster = mr$zq90,
  nStrata = 4
)

strat_quantiles(
  mraster = mr[[1:2]],
  nStrata = list(c(0.2, 0.4, 0.8), 3),
  map = TRUE
)


[Package sgsR version 1.4.5 Index]