calcStats: Ancillary function used in getTrainData_

View source: R/SOptim_GetTrainData.R

calcStatsR Documentation

Ancillary function used in getTrainData_

Description

Performs data aggregation ops necessary to calculate the percentage cover of each class (including: NoData or NA's) and subset it using the threshold rule.

Usage

calcStats(x, thresh = 0.5)

Arguments

x

A data.frame or matrix with two columns named: "SID" (segment ID's) and "train" (with train class or NA)

thresh

A threshold value defining the minimum proportion of the segment ]0, 1] that must be covered by a certain class to be considered as a training case. This threshold will only apply if x is a SpatRaster which means you are using train areas/pixels. If you are running a "single-class" problem then this threshold only applies to the class of interest (coded as 1's). Considering this, if a given segment has a proportion cover of that class higher than thresh then it is considered a train case. In contrast, for the background class (coded as 0's), only segments/objects totaly covered by that class are considered as train cases. If you are running a "multi-class" problem then thresh is applied differently. First, the train class is determined by a majority rule then if that class covers more than the value specified in thresh this case is kept in train data otherwise it will be filtered out. See also useThresh.

Value

A data.frame with training data.


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