绘制像素时间序列

问题描述 投票:0回答:1

我正在尝试创建光栅砖的交互式绘图,因此单击像素会为您提供该像素的时间序列数据。 (我的光栅砖大约是345张图片。)

这就是我做的:

library(raster)

EVI <- "D:\\Modis_EVI\\Original\\EVI_Stack_single5000.tif"
y.EVI <- brick(EVI)
plot(as.numeric(click(y.EVI)), type="l", lwd=2)

但它根本没有阴谋。当我尝试使用像4个图像的较小堆栈时,它只会出现此错误:

 Error in plot.window(…) : need finite 'xlim' values

有什么建议吗?

r plot time-series raster
1个回答
2
投票

假设您只想让用户单击一次,您应该在n=1中指定click。例如:

library(raster)
b <- brick(replicate(10, raster(matrix(runif(100), ncol=10))))

plot_ts <- function(x) {
  plot(x[[1]])
  z <- c(click(x, n=1, show=FALSE))
  plot(z, type='l', lwd=2, ylab='y', xlab='time', las=1)
  z
}

z <- plot_ts(b)

这是点击一个单元格后的示例图... enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.