R 如何在计算前用NA替换多个光栅中的某些值?
我正在用光栅文件做一些计算。我特别在计算移动平均线。 我想知道,在进行任何计算之前,hot如何为NA赋值R 如何在计算前用NA替换多个光栅中的某些值?,r,raster,R,Raster,我正在用光栅文件做一些计算。我特别在计算移动平均线。 我想知道,在进行任何计算之前,hot如何为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(f
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))
我也试过:
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))
f=堆栈(文件)
f[四舍五入(f,3)=-33999995214436420000000000000000000000.000]这是在单个光栅层中将NA设置为值的方式。一旦你这么做了,你可以随意堆叠
library(raster)
r1 <- raster(nrows=108, ncols=21, xmn=0, xmx=10)
r1[] <- runif(ncell(r1))
par(mfrow = c(1, 2))
plot(r1)
r1[500:1000] <- NA
plot(r1)
库(光栅)
r1这是在单个光栅图层中将NA设置为值的方式。一旦你这么做了,你可以随意堆叠
library(raster)
r1 <- raster(nrows=108, ncols=21, xmn=0, xmx=10)
r1[] <- runif(ncell(r1))
par(mfrow = c(1, 2))
plot(r1)
r1[500:1000] <- NA
plot(r1)
库(光栅)
r1files
只包含文件名的字符向量,而不是文件中的数据。您必须先读取数据。文件
只包含文件名的字符向量,而不是文件中的数据。您必须先读取数据。RasterStack
可以看作是一个列表。我添加了一个示例。这是一个匿名函数x
和y
也可以是arg1
和arg2
光栅堆栈
可以看作是一个列表。我添加了一个示例。这是一个匿名函数x
和y
也可以是arg1
和arg2
。
r <- stack(r1, r1, r1)
x <- list(c(100, 300), c(400, 600), c(800, 1000))
s <- mapply(FUN = function(x, y) {
y[x[1]:x[2]] <- NA
y
}, x = x, y = r)
plot(stack(s)) # not shown here