0

我有data.frame中边界椭球的x,y坐标。然后我query在 data.fame 中有几个 x,y 坐标。使用函数计算边界椭球的 x,y 坐标...

exy <- ellipsoidhull(X[,1:2])

这样……

plot(predict(exy), xlim=c(-0.018, 0.015), ylim=c(-0.018,0.015), 
     cex=0.1, type="l")

给我一个这样的情节....

在此处输入图像描述

我有这样的查询......

     V2      V3
-0.0167 -0.0137
-0.0159 -0.0127
-0.0150 -0.0127
-0.0164 -0.0137
-0.0164 -0.0134
-0.0173 -0.0131

如何找到query边界椭球内/外的哪个?是否有 R 函数可以做到这一点?谢谢

4

1 回答 1

2

mgcv提供了这样的功能(但不是唯一的 - 如果您想了解空间对象,请参阅,例如sp::overlay)。这是in.out()函数中的示例。

library(mgcv)
data(columb.polys)
bnd <- columb.polys[[2]]
plot(bnd,type="n")
polygon(bnd)
x <- seq(7.9,8.7,length=20)
y <- seq(13.7,14.3,length=20)
gr <- as.matrix(expand.grid(x,y))
inside <- in.out(bnd,gr)
points(gr,pch=as.numeric(inside)+1)

在此处输入图像描述

于 2011-03-15T08:32:50.137 回答