Learn R Programming

tripEstimation (version 0.0-46)

get.mask: Create, access and manipulate spatial masks

Description

Spatial masks are stored using the xyz-list structure used by image or as a series of masks stored as bits in the z-component as matrix or array object. get.mask is used to extract a specific mask from the binary storage, and mkSmall can be used to quickly down-sample an existing mask or image.

Usage

get.mask(masks, k)

mkSmall(lst, thin = 10)

set.mask(object, segment) <- value

mkMaskObject(xs, ys, nsegs)

Value

matrix of type logical

Arguments

masks

A list object with components x, y, and z containing spatial masks

k

specifies the k-th mask

lst

an xyz-list structure with z containing either a matrix or array

thin

integer factor to down-sample grid

object

array Mask object

segment

segment number to be modified in the mask

value

individual mask to be set

xs

x coordinates of mask cells

ys

y coordinates of mask cells

nsegs

number of segments to be represented

Author

Michael D. Sumner

See Also

mkLookup for the use of these masks to query individual locations and locations measured over time. See bits for the underlying mechanism to set and get mask bits.

For the use of the xyz-list structure see image.

Examples

Run this code

      data(volcano)
      d <- list(x = seq(-10, 10, length = nrow(volcano)),
                y = seq(-5, 5, length = ncol(volcano)),
                z = array(0L, c(nrow(volcano), ncol(volcano), 2)) )
      mv <- min(volcano)

      for (i in 0:61) {
        blk <- (i %/% 31) + 1
        bit <- (i - 1) %% 31
        bits(d$z[,,blk], bit) <- volcano > (mv + i*1.6 )
      }
      for (i in 0:61) image(get.mask(d, i))

      ## an object with 62 masks is only twice the size of the source data
      object.size(d) / object.size(volcano)

      ## plot a smaller version
      image(get.mask(d, 20), 5)


Run the code above in your browser using DataLab