假设我有这些栅格:
<chart exportenabled="1" showalternatehgridcolor="0" basefontsize="11" basefont="Roboto" showborder="0" bgcolor="#ffffff" showshadow="0" use3dlighting="0" legendshadow="0" legendbordercolor="ffffff" showlegend="1" useplotgradientcolor="0" showplotborder="0" showcanvasborder="0" palettecolors="26478d" useroundedges="0" labeldisplay="Rotate" slantlabels="1" yaxismaxvalue="100" yaxisminvalue="0" showvalues="1" yaxisname="Score" xaxisname="Month" caption="Quarterly Score Trends">
<set name="APR-JUN" value="4"> </set>
<set name="JUL-SEP" value="7"> </set>
<set name="OCT-DEC" value="3"> </set>
<set name="JAN-MAR" value="3"> </set>
</chart>
我有这个分类栅格:
library(raster)
r1 <- r2 <- r3 <- raster(ncol=10, nrow=10)
r1[] <- runif(ncell(r1))
r2[] <- runif(ncell(r2)) / 2
r3[] <- runif(ncell(r3)) * 1.5
s <- stack(r1, r2, r3)
我想计算堆栈 rs <- raster(ncol=10, nrow=10)
rs[] <-c(5,10,21,36,15)
中与s
相对应的所有像素的均值。
因此获得这样的内容:
5,10, etc (all values in rs)
答案 0 :(得分:0)
那将是“区域”的意思:
set.seed(1)
z <- zonal(s, rs, mean)
round(z, 2)
zone layer.1 layer.2 layer.3
[1,] 5 0.53 0.26 0.55
[2,] 10 0.50 0.23 0.51
[3,] 15 0.53 0.30 0.83
[4,] 21 0.52 0.22 0.71
[5,] 36 0.51 0.28 0.67
>