Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中绘制光栅堆栈中像素的时间序列图_R - Fatal编程技术网

如何在R中绘制光栅堆栈中像素的时间序列图

如何在R中绘制光栅堆栈中像素的时间序列图,r,R,我有一个由11个ascii文件组成的光栅堆栈,其中包含一个区域的温度值。每个文件表示不同的时间点,例如t2、t3、…、t12。我想从这个区域选择一个特定的像素,我想制作一个图表,显示这个像素的温度值在时间上的变化(从t2到t12)。我尝试了以下代码: > myfiles <- list.files(full.names = T) > temp_files <- stack(myfiles) > temp_values <- extract(temp_files

我有一个由11个ascii文件组成的光栅堆栈,其中包含一个区域的温度值。每个文件表示不同的时间点,例如t2、t3、…、t12。我想从这个区域选择一个特定的像素,我想制作一个图表,显示这个像素的温度值在时间上的变化(从t2到t12)。我尝试了以下代码:

> myfiles <- list.files(full.names = T)
> temp_files <- stack(myfiles)
> temp_values <- extract(temp_files, mypixel) # mypixel is defined by xyFromCell function
> plot(temp_values)
>myfiles临时文件临时值绘图(临时值)

我检查了这些值,结果似乎是对的。但我将对500层的堆栈应用相同的代码,我无法检查每个层中的每个值,因此这是正确的方法吗?

当问R问题时,请始终包括一个最小的、自包含的、可复制的示例——请参阅本网站或相关软件包的帮助页面以获取示例。像这样

library(raster)
r <- stack(system.file("external/rlogo.grd", package="raster")) 
所以你所做的似乎是正确的

x <- 1:nlayers(r)
# select the cell you want
y <- r[4089]
# or 
# extract(r, 4089)
plot(x, y)