calculateSegmentStats: Calculate segment statistics for multiple raster features and...

View source: R/SOptim_CalcSegmentStats.R

calculateSegmentStatsR Documentation

Calculate segment statistics for multiple raster features and aggregation functions

Description

This function allows calculating aggregation statistics by segment ID to be used in the classification stage. This function employs dtplyr (based on data.table) and dplyr verbs for processing.

Usage

calculateSegmentStats(
  rstFeatures,
  rstSegm,
  funs = c("mean", "sd"),
  na.rm = TRUE,
  bylayer = FALSE,
  tiles = NULL,
  subset = NULL,
  progressBar = FALSE
)

Arguments

rstFeatures

A string defining the path to the raster features or a SpatRaster object.

rstSegm

A string defining the path to the raster with segment IDs or a SpatRaster object.

funs

A character vector with the name(s) of the functions used to aggregate data (default: c("mean", "sd")).

na.rm

Boolean defining if NA's should be removed (default: TRUE).

bylayer

Calculate statistics layer by layer instead of all at once? (slightly increases computation time but spares memory load; default: FALSE).

tiles

Number of times to slice the SpatRaster across row and column direction. The total number of tiles will be given by: N_{tiles} = nd^{2}.

subset

A vector defining which segments should be selected.

progressBar

Boolean. Show progress bar? (default: FALSE).

Value

A data frame containing segment ids (first column, SID) and aggregated features. The name of the aggregation function will be appended to the name of each raster feature.


joaofgoncalves/SegOptim documentation built on Feb. 5, 2024, 11:10 p.m.