Standards /

WCPS-Tutorial / Trimming: how to do interval subsetting

Trimming a coverage extracts a cutout along the axis indicated, specified by a lower and upper bound on this axis. Obviously, as we talk about subsetting, the new interval limits must lie inside the original coverage's domain.

Example: Coverage mowglie is a 3-D RGB cube with axes x, y, and time. Actually, as you may realize, this is a downscaled excerpt from Walt Disney's Jungle Book where the image frames have been stacked along the time axis.

To get an impression of this time series stack see the image below, or download this coverage as an mpeg stream.

in WCPS Abstract Syntax this is expressed using the previously introduced request:

for m in ( mowglie )
return
        encode( m, "mpeg" )

On this cube, we perform subsetting to get a cutout along x axis between 90 and 110 and along y axis between 60 and 90.

for m in ( mowglie )
return
        encode( trim( m, trim( m, x(90:100) ), y(60:90) ), "mpeg" )

The first frame of this video cutout is displayed below:

Background information:

  • There are shorthands available for combining trimming and slicing within one expression, see the resp. manual section.
  • Interval limits can be expressed in a coverage's image CRS or any CRS which the coverage supports.
  • Another domain function, extending, allows to specify new limits which may lie outside the original coverage's domain. Exterior values will be set to null then.

See manual: trimExpr