I have several rasters with values from 0 to 7, and I want to reclassify pixels using 3 different areas and different conditions.
I want to reclass
rc1
pixel value of (1 or 3 or 5 or 7) to 1
rc2
pixel value of (2 or 3 or 6 or 7) reclassify to 1
rc3
pixel value of (4 or 5 or 6 or 7) reclassify to 1 and
then combine the three raster objects to the final raster with only values of 0, 1 or NA.
border1 <- terra:vect("")
border2 <- terra:vect("")
border3 <- terra:vect("")
r <- terra::rast("filename.tif")
rc1 <- terra::mask(r, border1)
rr1 <- terra::classify(rc1, ?????)
rc2 <- terra::mask(r, border2)
rr2 <- terra::classify(rc2, ?????)
rc3 <- terra::mask(r, border3)
rr3 <- terra::classify(rc3, ?????)
final <- terra::app(c(rr1, rr2, rr2), max, na.rm = TRUE)