I am having trouble figuring out the best way to create a new raster from values in two separate rasters. Some solutions involve creating stacks or bricks, others do not.
Here is an example:
First raster is "propSummPCPmod4"
Determine frequency of values
freq(propSummPCPmod4)
value count
[1,] 1 1417084
[2,] 3 9103585
[3,] NA 14535331
Second raster is "propWintPCPmod4"
Determine frequency of values
freq(propWintPCPmod4)
value count
[1,] 2 241512
[2,] 3 10279157
[3,] NA 14535331
create a brick and plot both rasters side by side
brick1 <- brick(propSummPCPmod4, propWintPCPmod4)
plot(brick1, col=terrain.colors(255))
The plot shows that values of 1 from "propSummPCPmod4" [layer 1] and values of 2 from "propWintPCPmod4" [layer 2] do not overlap.
I want to a create a new raster and to employ the "1" values from propSummPCPmod4, the "2" values from propWintPCPmod4, and to have all other values represented by "3" or NA. (NA values are outside the boundaries of the original source rasters)
I tried merge, cvr, overlay, and mask but couldn't get a satisfactory result.