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?

  • Take a look at the 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. – Jeffrey Evans Jul 26 '20 at 0:28

I was unable to figure this out. Since the scenes I am working with do not have any visible cloud cover in them, I don't need to fret about this. But I would like to know how it could be done. However, one easy way to deal with cloud cover could be adding training sites on visible cloud cover and then masking them out based on the cloud cover class developed during supervised classification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.