如果我有一组这样创建的 SpatialPolygons:
library(sp)
Sr2 = Polygon(cbind(c(2,2,1,2,4,4,2),c(2,6,7,7,5,3,2)))
Sr3 = Polygon(cbind(c(4,4,2,5,10,4),c(5,3,2,2,5,5)))
Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
Srs2 = Polygons(list(Sr2), "s2")
Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
SpP = SpatialPolygons(list(Srs2, Srs3), 1:2)
plot(SpP, col = 2:3, pbg = "white")
这样它看起来像这样:
以及由以下内容创建的点向量:
x <- c(2, 1, 3, 4, 2, 2)
y <- c(2, 4, 2, 2, 3, 4)
points <- cbind(x, y)
如果有的话,我如何检测哪些点位于哪个多边形内?
谢谢