开发者

query x,y coordinates inside/outside bounding ellipsoid

I have the x,y co-ordinates for a bounding ellipsoid in a data.frame. And then I have several query x,y co-ordinates in a data.fame. The x,y co-ordinates for a bounding ellipsoid was calculated using the function...

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

such that....

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

gives me a plot like this....

query x,y coordinates inside/outside bounding ellipsoid

开发者_JS百科

I have query like this....

     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

How can I find which of the query is within/outside the bounding ellipsoid? Is there an R function to do this? Thanks


Package mgcv offers such function (but is not the only one - if you care to learn about spatial objects, see, for example, sp::overlay). This is example from the in.out() function.

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)

query x,y coordinates inside/outside bounding ellipsoid

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜