I am trying to create a single raster from two rasters. The first raster is made up of all 0 values and the second is made up of the current date value (formatted in days from 001 to 365). The problem is using raster overlay I am struggling to get the result I am after. I can combine the to using the following without any issue:
zeroRaster <- overlay(changeDate, zeroRaster, fun=function(x,y){return(x+y)})
however when a specific cell changes multiple times the two dates are added together which is obviously incorrect (with the x+y function being to blame).
As I am struggling to explain I will try and visually represent what I am trying to achieve below:
Essentially I just want to replace any cell value in raster y with the new date value from raster x without performing any mathematical functions.