I tried to use the RStoolbox
package function classifyQA
to generate information on quality of the layers of interest, namely - cloud, cloud shadows, and water. I am unable to understand how to mask clouds and water using this function.
#One of the attempts
cloudMask(img,crop_pixelqaband_1992) # trying to use the pixel QA band provided by SR products to create a mask. I understand right now the code is not specific in pulling out only the cloud and cloud shadow data from the QA band layer.
Return error
Error in .local(x, ...) : invalid layer names # the function only seems to take blue and thermal bands
May be I am doing this wrong? Is there another way to do cloud and water masking using Landsat surface reflectance products that do not provide thermal bands in R? Can someone please suggest how one can go about carrying out masking for clouds and water in R using the pixel quality band of SR products?
parse.bits
function in the spatialEco package. You will need to look up the bit definitions for landsat. The example in the functions help is for MODIS but, exactly the same idea for creating a mask.