我有一堆栅格。
## read the libraries
library(raster)
library(rgdal)
library(sp)
##random raster object
r <- raster(ncol=40, nrow=20)
r[] <- rnorm(n=ncell(r))
# Create a RasterStack object with 3 layers
s <- stack(x=c(r, r*2, r**2))
##coordinate system
wgs<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
##plotting with spplot
plot(spplot(s,layout=c(2,2),
colorkey =list(space = "right"),
names.attr = c("a","b","c")))
到目前为止,我已经在layout=c(2,2)
中绘制了栅格堆栈。现在,在空的第二行和第二列中,我想将栅格堆栈的平均值绘制为线图。像这样...
plot(cellStats(s, stat='mean', na.rm=TRUE,
asSample=TRUE),type="l",ylab="mean",xlab="value")
有人可以帮我吗?