Can someone please tell me how will I discard the clouds from Landsat 8 images using R? I have used the code
LC08_20151128_new <- cloudMask(LC08_20151128, threshold = 0.8, blue = "layer.1", tir = "layer.9", buffer = NULL, plot = FALSE)
I read that for landsat 8 layer 1 and layer 9 might be useful to detect the clouds. Is it correct? I got the image below after runninng the code
And then I masked the image with the cloudMask
LC08_20151128_crop <- mask(LC08_20151128,LC08_20151128_new, maskvalue = NA)
But it seems that the code retains the area with the cloud cover instead of removing it. Please see the RGB image below
Best Answer
Below code provides a reproducible example using the Landsat 8 scene 'LC08_L1TP_195025_20130707_20170503_01_T1' (Collection 1 Level-1) which is roughly centered on Frankfurt am Main, Germany, and was downloaded from USGS Earth Explorer. In order to discard all cloudy pixels (ie set them to
NA
), which I assume is your overall goal, specify eithermaskvalue = 1
ormaskvalue = NA, inverse = TRUE
inside your
raster::mask()
call. Have a look at the function's help pages for further details.