12 個のバイナリ (ラスター) ファイルがあります。12 個のファイルの各ピクセルの 12 個の値の移動平均を計算したいと思います。
単純なベクトルの場合、これを使用して移動平均を取得できます。
x <- c(1,2,3,NA,NA,4,6,5,6,4,2,5)
movingmean <- rollapply(x, 3, FUN = mean, na.rm = T,fill=NA)
今、私は同じことをしたいのですが、ラスターを使って試しました:
files <- list.files("C:final-2010", "*.envi", full.names = TRUE)
results <- list()
for (.files in files) {
# read in the 12 files as a vector of numbers
# that we take the average of
x <- do.call(rbind,(lapply(.files, readBin , double() ,
size = 4 ,n =1440 * 720 , signed = T)))
# take the moving average across the 12 values
# from the 12 files for each pixel
results[[length(results) + 1L]] <- rollapply(x, 3, FUN = mean,na.rm = T)
}
しかし、このエラーが発生しました:
Error in seq.default(start.at, NROW(data), by = by) :
wrong sign in 'by' argument