Skip to main content
adding some code
Source Link
JPD
  • 1.7k
  • 2
  • 20
  • 33

The glcm function outputs a stack, with each band containing values for each of the statistics calculated. By default, all available statistics are computed.

You won't be able to put this stack into a single band within the brick as you are trying with band[i]<-. This is probably what is giving you the error message.

One solution would be to output each stack to a list and then look at stacking them together once the loop has completed.

Something like this should work:

out <- list()

for(i in 1:dim(LS)[3]) {
  
  out[i] <- glcm::glcm(LS[[i]], window = c(3, 3), na_opt = 'center')
  
}

The glcm function outputs a stack, with each band containing values for each of the statistics calculated. By default, all available statistics are computed.

You won't be able to put this stack into a single band within the brick as you are trying with band[i]<-. This is probably what is giving you the error message.

One solution would be to output each stack to a list and then look at stacking them together once the loop has completed.

The glcm function outputs a stack, with each band containing values for each of the statistics calculated. By default, all available statistics are computed.

You won't be able to put this stack into a single band within the brick as you are trying with band[i]<-. This is probably what is giving you the error message.

One solution would be to output each stack to a list and then look at stacking them together once the loop has completed.

Something like this should work:

out <- list()

for(i in 1:dim(LS)[3]) {
  
  out[i] <- glcm::glcm(LS[[i]], window = c(3, 3), na_opt = 'center')
  
}
Source Link
JPD
  • 1.7k
  • 2
  • 20
  • 33

The glcm function outputs a stack, with each band containing values for each of the statistics calculated. By default, all available statistics are computed.

You won't be able to put this stack into a single band within the brick as you are trying with band[i]<-. This is probably what is giving you the error message.

One solution would be to output each stack to a list and then look at stacking them together once the loop has completed.