Dear List, I have two raster layers (r1 and r2) and the cells have values ranging 1 to 10. I want to create a new raster layer from these two with different conditions like: 1) if r1==1 and r2==1, then r3 should be 1 2) if r1==1 and r2==2, then r3 should be 2 else 0 etc
With the following example: m1<-matrix(c(1,1,1,2,2,2,3,3,3),ncol=3,byrow=TRUE) m2<-matrix(c(1,2,1,1,2,3,2,3,3),ncol=3,byrow=TRUE) r1<-raster(m1) r2<-raster(m2) Here, r1[1,1]=1 and r2[1,1]=1, so for the new raster, [1,1] should be 1, r1[1,2]=1 and r2[1,2]=2, so for the new raster, [1,2] should be 2, all other cells which don't satisfy the above criteria should be zero. I tried with "calc" in raster package but the attempt was not successful. Looking forward to your suggestions! Thanks -- Ani [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo