Let's assume I have a raster representing land use classes in a certain resolution. I have to aggregate this raster with R to a coarser resolution and a modal value approach, in order to have the most dominating cell value in the coarser raster. This is easily achieved with
m <- aggregate(r, fact = 3, fun = modal, na.rm = TRUE)
However, I would like to weight the different land use classes – e.g. forest class (code 1) has a weight of 4 while water class (code 2) has a weight of 2 and street class has a weight of 1.
Is there a function that iterates through raster cells and applies a weight for each cell?
Thanks for any help?