我正在用光栅文件进行一些计算,特别是计算移动平均值。 我想知道热在任何计算之前将值赋给NA。如何在计算之前用几个栅格中的NA替换某些值?
Here is the code :
files <- list.files("C:final-2010", "*.envi", full.names = TRUE)
files[round(files,3) == -339999995214436420000000000000000000000.000 ] <- NA
d1 <- overlay(stack(files),fun=function(x) movingFun(x, fun=mean, n=3, na.rm=TRUE))
但我得到了一个错误:
Error in round(files, 3) : Non-numeric argument to mathematical function
我想这也:
f=stack(files)
f[round(f,3) == -339999995214436420000000000000000000000.000 ] <- NA
movi <- overlay(stack(f),fun=function(x) movingFun(x, fun=mean, n=3, na.rm=TRUE))
没有错误,但是当我看了看,结果我发现,什么也没有改变。
'files'只包含文件名,而不是在文件中的数据的特征向量。你必须先读取数据。 – juba 2013-02-20 12:46:46