get.mask: Create, access and manipulate spatial masks

Description Usage Arguments Author(s) See Also Examples

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

1
2
3
4
5
6
7
get.mask(masks, k)

mkSmall(lst, thin = 10)

set.mask(object, segment) <-  value

mkMaskObject(xs, ys, nsegs)

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(s)

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
      data(volcano)
      d <- list(x = seq(-10, 10, length = nrow(volcano)), 
                y = seq(-5, 5, length = ncol(volcano)),
                z = array(0, 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)
      
      ## Not run: 
      ## plot a smaller version
      image(get.mask(d, 20), 5)
      
       ## pretend we have only one masks
      lookup <- mkLookup(get.mask(d, 30), by.segment = FALSE)
      
      ## interactive to show use of lookup function
      image(get.mask(d, 30), main = "Click on the red (FALSE) and cream (TRUE) areas")
      for (i in 1:10) {x <- matrix(unlist(locator(1)), ncol = 2);text(x[1], x[2], lookup(x) > 0)}
      
## End(Not run)
      

tripEstimation documentation built on May 2, 2019, 4:59 p.m.