I would like to calculate glcm function in R for all (52) bands in my RasterStack. Using this code:
LS<-stack(img1,img2,img3,img4,img5,img6,img7,img8,img9,img10,img11,img12,img13)
names(LS) <- paste0("B", c(1:52))
band<-brick()
for (i in 1:52){
band[i]<-glcm(LS$B1,window = c(3, 3),na_opt = 'center')
}
I get 1 layer RasterBrick with NA values and an error message: 1: In x@data@values[i] <- value : number of items to replace is not a multiple of replacement length
Do you know how to get the result for all the bands in my RasterStack?
i
?glcm
onimg1
before stacking it with anything else? If so, do you get the same error message?glcm(LS$B1,window = c(3, 3),na_opt = 'center')
band
is astack
instead of abrick
?