1

I am trying to use the clouds function of the landsat r package to identify clouds in my LANDSAT 8 scene.

In the package help, it is said that reflectance bands 1 and 6 should be used:

clouds(band1, band6, level = 0.0014, buffer=5)

where bands 1 and 6 are data frames.

I have done so, with the following code:

p198r054_sr<-stack("LC08_L1TP_198054_20140205_20170426_01_T1_sr_band1.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band2.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band3.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band4.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band5.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band6.tif",
                   "LC08_L1TP_198054_20140205_20170426_01_T1_sr_band7.tif")
p198r054_band1<-p198r054_sr$LC08_L1TP_198054_20140205_20170426_01_T1_sr_band1
p198r054_band6<-p198r054_sr$LC08_L1TP_198054_20140205_20170426_01_T1_sr_band6
p198r054_band1<-as.data.frame(p198r054_band1, row.names=NULL, optional=FALSE, xy=TRUE, 
                              na.rm=FALSE, long=FALSE)
p198r054_band6<-as.data.frame(p198r054_band6, row.names=NULL, optional=FALSE, xy=TRUE, 
                              na.rm=FALSE, long=FALSE)

Using my two bands gives me the following message (using default threshold):

p198r054_clouds<-clouds(p198r054_band1, p198r054_band6, buffer=5)

Error in x[(i - mwoffset):(i + mwoffset), (j - mwoffset):(j + mwoffset)] : 
      subscript out of bounds

Could this error be due to the fact that I am using the wrong bands? I don't know if the package was meant for LANDSAT 7 or 8 images?

1

Always check function documentation:

References

This function is loosely based on: Martinuzzi, S., Gould, W.A., Ramos Gonzales, O.M. 2007. Creating Cloud-Free Landsat ETM+ Data Sets in Tropical Landscapes: Cloud and Cloud-Shadow Removal. USDA Forest Service General Technical Report IITF-GTR-32.

From Martinuzzi et al. 2007:

... We have developed a simple and semiautomated method to mask clouds and shadows in Landsat ETM+ imagery... We created cloud masks by using Landsat ETM+ band 1 (blue) and thermal band 6.1 ...

Cloud Masking

• Brightness values for clouds were identified by visual analysis. For band 1, DN values between 120 and 255 include clouds as well as urban, barren, quarries, rocks, and sand. For band 6, DN values of 102 to 128 include both clouds and densely forested areas.

Also, landsat package is from 2012, I recommend you to use RStoolbox (Last update 2017-08-22). You can use cloudMask function:

enter image description here

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.