Standards /

WCPS-Tutorial / General condensers

The general condenser is a powerful tool for summarising data, in particular in conjunction with the coverage constructor introduced later. The ingredients for a condenser are a coverage (or coverage expression), a domain (or subdomain) of this coverage to iterate over, an expression to be evaluated for each cell inspected, and finally a summarization function to aggregate all values obtained.

Example:: "The maximum value of the rgb green band."

for c in ( rgb )
return
	condense max
	over     p in imageCrsDomain(c)
	using    c[p]

Function imageCrsDomain(c) returns the coverage extent in its ImageCRS that is: in integer cell coordinates. The cell expression c[p] simply takes the value addressd by the current position p. Not surprisingly, this condense expression in fact is equivalent (and defines) the shorthand max(c).

However, in contrast to the shorthands, where the coordinates do not appear, random addressing is possible in a general condenser. For a meaningful example on this we need to introduce the coverage constructor in the next section.

Background information:

  • Any summarisation function s() is admissible as long as it has the following properties:
    • s() is a binary function between values of the coverage range type;
    • s() is commutative and associative.
    For example, binary + on floating point numbers is admissible for a condenser on a float coverage, while binary - is not.
  • Note that iteration sequence over the coverage is left open - it is just assured that each cell will be evaluated exactly once, but not when during iteration.

See manual: generalCondenseExpr