the*_*ist 5 r polygon footprint scatter-plot concave-hull
我在“足迹”形状非常不规则的区域中有一系列要点:
我想确定轮廓线顶点内的所有坐标。最终目标是确定哪些数据点不在此覆盖范围内。
有没有人有一个有效的方法去做呢?
我最好的解决方法是根据绿色区域的顶点绘制一个多边形,然后使用该多边形的坐标来确定“离群点”(尽管我不确定该怎么做,一次只一步) !)。
但是,当我尝试创建凸包时,由于绿色空间的形状不规则,显然会产生问题。[有人知道创建CONVAVE船体的方法吗?]
或者,是否可以使用“单击图形”类型的方法手动绘制多边形?
...同样,如果您对我的问题有比使用多边形更好的解决方案,请务必提出解决方案!
或者,有没有一种方法可以使用“单击图形”类型的方法手动绘制多边形?
这是一个想法。首先,一些随机点:
library(manipulate)
library(sp)
set.seed(1)
par(pch = 19, cex=.5)
x <- runif(1000)
y <- runif(1000)
Run Code Online (Sandbox Code Playgroud)
现在,绘制并捕获多边形:
coords <- data.frame()
manipulate({
plot(y~x)
res <- manipulatorMouseClick()
coords <<- rbind(coords, data.frame(x=res$userX, y=res$userY))
if (length(coords)) lines(coords)
})
Run Code Online (Sandbox Code Playgroud)
并确定哪些点位于其内部/外部(请参阅?point.in.polygon):
res <- point.in.polygon(x, y, coords$x, coords$y)!=0
plot(y~x, col = res + 1L)
lines(coords)
Run Code Online (Sandbox Code Playgroud)