Ops.global_group: Extract certains statistics for whole image

global operatorR Documentation

Extract certains statistics for whole image

Description

Function from this ⁠global.⁠⁠FUN⁠ list returns required statistics FUN for the whole image.

Usage

global_mean(x, ursa = FALSE, ...)
global_median(x, ursa = FALSE, ...)
global_sd(x, ursa = FALSE, ...)
global_sum(x, ursa = FALSE, ...)
global_min(x, ursa = FALSE, ...)
global_max(x, ursa = FALSE, ...)
global_n(x, ursa = FALSE, ...)
global_nNA(x, ursa = FALSE, ...)
global_range(x, ursa = FALSE, ...)
global_quantile(x, ursa = FALSE, ...)

Arguments

x

Object of class ursaRaster.

ursa

Logical. The class of returned value. If FALSE then numeric vector of length one is returned (for global_range vector has length two). If TRUE then returned value is single-band raster image (two-bands image for global_range) with constant value for all cells (blank image). Default is FALSE.

...

Arguments in function ⁠global.⁠⁠FUN⁠ which are passed to function ⁠FUN⁠.

Details

For any function ⁠global⁠.⁠FUN⁠, if argument na.rm is not in ..., then ⁠FUN⁠ is called with forced na.rm=TRUE.

⁠global_range\emph{list of arguments}⁠ is implemented as ⁠c(global_min(⁠⁠list of arguments⁠⁠), global_max(⁠⁠list of arguments⁠⁠))⁠ with the same list of arguments.

Alternative method to get global statistics is function applying directly to the raster value. For example, sd(ursa_value(x,na.rm=TRUE)). This way is also appropriate for missing global functions: for example, var(ursa_value(x,na.rm=TRUE)).

Value

If ursa=FALSE then numeric.
If ursa=TRUE then object of class ursaRaster.

Author(s)

Nikita Platonov platonov@sevin.ru

Examples

session_grid(NULL)
a <- ursa_dummy(2,min=-40,max=80)
a[a<0] <- NA
print(a)
a.mean <- global_mean(a)
a.sd <- global_sd(a)
a.sum <- global_sum(a)
a.min <- global_min(a)
a.max <- global_max(a)
a.median <- global_median(a)
print(c(mean=a.mean,sd=a.sd,sum=a.sum,min=a.min,max=a.max,median=a.median))
v.max <- max(ursa_value(a),na.rm=TRUE)
print(c('global_max()'=a.max,'max(ursa_value())'=v.max,dif=a.max-v.max))
r.max <- global_max(a,ursa=TRUE)
print(r.max)
b <- c(a,'appended scalar value'=a.max)
print(b)
print(global_quantile(a))

nplatonov/ursa documentation built on Feb. 2, 2024, 4:08 a.m.