我正在从shp文件中绘制空间样本。通过这种方式:
pr <- readShapePoly("PuertoRico.shp")
n <- 90
samp.reg <- spsample(pr, n, type="regular")
这就是我得到的:
samp.reg
SpatialPoints:
x1 x2
#[1,] -66.15482 17.93279
#[2,] -67.15842 18.02403
#[3,] -67.06718 18.02403
#[4,] -66.97595 18.02403
#[5,] -66.88471 18.02403
以此类推,直到[90,]
现在,我想提取
刚刚绘制的样本中包含的观察结果
,不仅包含坐标,还包含我需要研究的连接变量(即高程)。
下面你可以看到数据帧的样子。
df <- read.csv("pr_elev_rs.csv",header=TRUE)
head(df)
Label x y elevation
1 BL192 -67.27045 18.36269 0
2 BM191 -67.26450 18.36761 30
3 BM192 -67.26490 18.36020 56
4 BM193 -67.26287 18.35222 0
5 BM194 -67.26075 18.34632 0
6 BN190 -67.25191 18.37403 10
我是R的初学者,我不知道该怎么做。谢谢你的帮助,我真的很需要。