Standards /

WCPS-Tutorial / Condensers shorthand

Similar to what SQL aggregates do on sets, the condenser shorthands allow to obtain summary information about coverages.

Example: "the average of the red components of all cells in the image".

for c in ( rgb )
return
	avg( c.red )

The following table lists the shorthands available; a is assumed to be a numeric, b a Boolean coverage expression.

condenser meaning
add(a) sum over all cells in a
avg(a) average of all cells in a
min(a) minimum of all cells in a
max(a) maximum of all cells in a
count(b) number of cells in b containing true / non-zero values
some(b) is there any cell in b with value true?
all(b) do all cells of b have value true?

Example: "the number of vegetation pixels in satScene."

for s in ( satScene )
return
        count( (s.0-s.1)/(s.0+s.1) > 0.6 )

The response is a single integer number, so no encode() is needed.

See manual: reduceExpr