strat_breaks {sgsR}R Documentation

Breaks stratification

Description

Stratify metrics raster using user defined breaks

Usage

strat_breaks(
  mraster,
  breaks,
  map = FALSE,
  plot = FALSE,
  details = FALSE,
  filename = NULL,
  overwrite = FALSE
)

Arguments

mraster

Spatraster. Raster to stratify. Layers in mraster must match the number of breaks vectors provided.

breaks

Numeric. Vector of breakpoints for each layer of mraster. If mraster has multiple layers, breaks 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. raster is a stratified spatRaster based on quantiles. If stack = TRUE will be the number of layers of mraster plus the final output

  2. breaks is a list output of breaks

  3. plot is a ggplot histogram object showing distribution(s) and break point(s).

Author(s)

Tristan R.H. Goodbody

See Also

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

Examples

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

#--- create vector breaks ---#
br.zq90 <- c(3, 5, 11, 18)
br.pz2 <- c(20, 40, 60, 80)

strat_breaks(
  mraster = mr$zq90,
  breaks = br.zq90
)


strat_breaks(
  mraster = mr[[1:2]],
  breaks = list(br.zq90, br.pz2),
  details = TRUE
)

[Package sgsR version 1.4.5 Index]