Skip to contents

Fixed intervals use (-Inf, b1], (b1, b2], ..., (bn, Inf) when right = TRUE; with right = FALSE, boundary values move to the upper interval. Quantile thresholds use type-7 quantiles within reference groups. Groups below min_n (default 30) are returned as NA and reported in one warning. Defaults are literature schemes; direction records whether higher or lower values are better and does not reverse the interval order.

Usage

wapor_classify(
  x,
  breaks = NULL,
  labels = NULL,
  method = c("fixed", "quantile"),
  reference = NULL,
  id = NULL,
  scheme = NULL,
  right = TRUE,
  min_n = 30
)

Arguments

x

Numeric vector or a terra SpatRaster.

breaks

Break values, or probabilities for method = "quantile".

labels

Class labels, one more than breaks.

method

Classification method, "fixed" or "quantile".

reference

Optional grouping vector, SpatRaster, or polygon data.

id

Polygon attribute used for reference groups.

scheme

Optional default scheme.

right

Logical interval closure.

min_n

Minimum observations per quantile group.

Value

An integer categorical SpatRaster or factor.

Details

Scheme defaults from wapor_class_defaults() (every scheme has a source):

schememethodbreakslabelsdirectionsource
adequacyfixed0.68, 0.80, 1.00poor, acceptable, good, above ETchigher_betterKarimi et al. (2019); Chukalla et al. (2022)
equityfixed0.10, 0.25good, fair, poorlower_betterBastiaanssen et al. (1996); Karimi et al. (2019)
uniformity_surfacefixed0.65below standard, meets standardhigher_betterPitts et al. (1996)
uniformity_sprinklerfixed0.75below standard, meets standardhigher_betterPitts et al. (1996)
uniformity_pivotfixed0.75below standard, meets standardhigher_betterPitts et al. (1996)
uniformity_dripfixed0.85below standard, meets standardhigher_betterPitts et al. (1996)
spotsquantile0.05, 0.95dark, normal, brighthigher_betterChukalla et al. (2020) WAPORWP Module 5

Class 4 of adequacy is labelled "above ETc". It is a package class, not a published over-irrigation class. Uniformity schemes are per irrigation method, not one ordinal scale. Project overrides: options(Rwapor.class_breaks).

Examples

wapor_classify(c(0.68, 0.8, 1, 1.01), scheme = "adequacy")
#> [1] poor       acceptable good       above ETc 
#> attr(,"wapor_classes")
#> attr(,"wapor_classes")$scheme
#> [1] adequacy
#> 
#> attr(,"wapor_classes")$method
#> [1] fixed
#> 
#> attr(,"wapor_classes")$breaks
#> [1] 0.68 0.80 1.00
#> 
#> attr(,"wapor_classes")$labels
#> [1] poor       acceptable good       above ETc 
#> 
#> attr(,"wapor_classes")$right
#> [1] TRUE
#> 
#> attr(,"wapor_classes")$direction
#> [1] higher_better
#> 
#> attr(,"wapor_classes")$thresholds
#>   group   t1  t2 t3
#> 1   all 0.68 0.8  1
#> 
#> attr(,"wapor_classes")$source
#> [1] Karimi et al. (2019) Remote Sens. 11, 705; as applied in Chukalla et al. (2022) HESS 26, 2759-2778 (Sect. 2.3.2)
#> 
#> Levels: poor acceptable good above ETc