fmask: Fast masking of values in a Raster object

Description Usage Arguments Value References

Description

Create a new Raster* object that has the same values as x, except for the cells that are NA (or other maskvalue) in a 'mask'. These cells become NA (or other updatevalue). The mask can be either another Raster* object of the same extent and resolution, or a Spatial* object (e.g. SpatialPolygons) in which case all cells that are not covered by the Spatial object are set to updatevalue. You can use inverse=TRUE to set the cells that are not NA (or other maskvalue) in the mask, or not covered by the Spatial* object, to NA (or other updatvalue).

Usage

 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
fmask(x, mask, ...)

## S4 method for signature 'Raster,sf'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

## S4 method for signature 'Raster,Spatial'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

## S4 method for signature 'RasterLayer,RasterLayer'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  maskvalue = NA,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

## S4 method for signature 'RasterStackBrick,RasterLayer'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  maskvalue = NA,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

## S4 method for signature 'RasterLayer,RasterStackBrick'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  maskvalue = NA,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

## S4 method for signature 'RasterStackBrick,RasterStackBrick'
fmask(
  x,
  mask,
  filename = "",
  inverse = FALSE,
  maskvalue = NA,
  updatevalue = NA,
  updateNA = FALSE,
  ...
)

Arguments

x

Raster* object

mask

Raster* object or a Spatial* object from sf or sp classes

...

additional arguments as in writeRaster

filename

character. Optional output filename

inverse

logical. If TRUE, areas on mask that are _not_ the maskvalue are masked

updatevalue

numeric. The value that cells of x should become if they are not covered by mask (and not NA)

updateNA

logical. If TRUE, NA values outside the masked area are also updated to the the updatevalue (only relevant if the updatevalue is not NA

maskvalue

numeric. The value in mask that indicates the cells of x that should become updatevalue (default = NA)

Value

A raster of the same size, extent, resolution and projection as the provided raster template.

References

Wylie, C., Romney, G., Evans, D., & Erdahl, A. (1967). Half-tone perspective drawings by computer. Proceedings of the November 14-16, 1967, Fall Joint Computer Conference. AFIPS '67 (Fall). <https://dx.doi.org/10.1145/1465611.1465619>


rinnan/fraster documentation built on May 22, 2020, 11:36 p.m.