我想创建一个网格,我用它:
reso = 0.25
xs <- seq(-180, 180, by=reso)
ys <- seq(-90, 90, by=reso)
grd <- expand.grid(
x=xs,
y=ys,
presence=0
)
head(grd)
这给了我这个,
x y presence
1 -180.00 -90 0
2 -179.75 -90 0
3 -179.50 -90 0
4 -179.25 -90 0
5 -179.00 -90 0
6 -178.75 -90 0
但是,我想要这个,
x y presence
-179.875 -89.875 0
-179.875 -89.625 0
-179.875 -89.375 0
-179.875 -89.125 0
-179.875 -88.875 0
-179.875 -88.625 0
-179.875 -88.375 0
-179.875 -88.125 0
-179.875 -87.875 0
-179.875 -87.625 0
-179.875 -87.375 0
-179.875 -87.125 0
-179.875 -86.875 0
-179.875 -86.625 0
-179.875 -86.375 0
Please note how the x and y increases.
答案 0 :(得分:3)
reso <- 0.25
xs <- seq(-179.875, 179.875, reso)
ys <- seq(-89.875, 89.875, reso)
grd <- expand.grid(y=ys, x=xs, presence=0)
grd <- grd[,c(2,1,3)]
head(grd)
# x y presence
# 1 -179.875 -89.875 0
# 2 -179.875 -89.625 0
# 3 -179.875 -89.375 0
# 4 -179.875 -89.125 0
# 5 -179.875 -88.875 0
# 6 -179.875 -88.625 0