Skip to content
Prev 304845 / 398502 Next

repace values in raster based on values in another raster

Hi

The key information is how landuse.raster and fire.did.not.occurr objects looks like.
e.g. for matrix you can do
[,1]        [,2]       [,3]        [,4]
[1,] -0.08281164 100.0000000 -1.1249003 100.0000000
[2,]          NA          NA -0.8743036          NA
[3,] -2.05128979          NA         NA          NA
[4,]          NA          NA -0.5839751 100.0000000
[5,] -1.52596060  -0.5604825 -0.8232986  -0.3804572

if lat is one value. If it is matrix with the same dimensions as mat you need to do it differently.
Warning message:
In mat[fat == 1] <- lat :
  number of items to replace is not a multiple of replacement length
[,1]       [,2]       [,3]       [,4]
[1,] -0.08281164 24.1093483 -1.1249003 38.9556712
[2,]          NA         NA -0.8743036         NA
[3,] -2.05128979         NA         NA         NA
[4,]          NA         NA -0.5839751 61.7859617
[5,] -1.52596060 -0.5604825 -0.8232986 -0.3804572
[,1]       [,2]       [,3]       [,4]
[1,] -0.08281164 41.0170721 -1.1249003 15.3955547
[2,]          NA         NA -0.8743036         NA
[3,] -2.05128979         NA         NA         NA
[4,]          NA         NA -0.5839751  3.0707204
[5,] -1.52596060 -0.5604825 -0.8232986 -0.3804572

Regards
Petr