我正在计算时间序列栅格与时间数据的趋势,但由于NA和零值,我得不到正确的结果..
在下面的示例中,给出了像素的值。由于零值,我得到斜率值为-23.275而不是3.897
time Value
1 289
2 289
3 353
4 305
5 0
6 0
7 385
8 0
9 0
10 305
11 0
12 0
13 0
14 0
15 0
correct form should be like this
Time Value
1 289
2 289
3 353
4 305
7 385
10 305
我的示例代码是
library(raster)
setwd("F:\\PHD_work\\Paper_work\\EOS\\New folder")
eos = stack(list.files(pattern='*.img'))
time = 1:nlayers(eos)
f_slope=function(x) { if (is.na(x[1])){ NA } else { m = lm(x ~ time); summary(m)$coefficients[2] }}
z = calc(eos, f_slope)
y = writeRaster(z, filename = "slope", format = "HFA")
答案 0 :(得分:0)
数据位于curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Cache-Control: no-cache" -H "Postman-Token: 655d9932-4681-f23d-6caf-5fcf63c10b82" -d 'grant_type=client_credentials&client_id=name/a+@b.com&client_secret=XXX!' "https ://example.com/admin/v100/api/oauth/token"
,使用S4
更改z
中的值
@
但由于问题中没有说明,我还会保持正常过滤
使用z@data@values <- z@data@values[z@data@values > 0]
dplyr
或eos <- eos %>% na.omit() %>% filter(Value>0)
base