I am removing clouds from a raster stack of 768 pixel_qa bands which are provided by USGS as part of surface reflectance product. The details of raster stack (qa) are:
> qa
class : RasterStack
dimensions : 2520, 2714, 6839280, 768 (nrow, ncol, ncell, nlayers)
resolution : 30, 30 (x, y)
extent : 205755, 287175, 3950955, 4026555 (xmin, xmax, ymin, ymax)
crs : +proj=utm +zone=43 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
Before I use this qa raster stack to mask NDVI stack, I use the following code to replace cloud values to NA:
> qa[qa %in% c(224, 480, 992)] <- NA
where 224 is cloud pixel value for Landsat 4-7 and 480 & 992 for Landsat 8.
The code runs forever! What could be wrong here?