[R] problem with pip2d() from ptinpoly

Waichler, Scott R Scott.Waichler at pnnl.gov
Sat Apr 19 00:00:12 CEST 2014


Hi,

pip2d() doesn't seem to work correctly for me.  I have a plot of a triangle that a query point fits inside, but the point is defined as outside the polygon by pip2d.  

library(ptinpoly)
verts <- matrix(c(594891,115309,594444,117201,594891,117201), ncol=2, byrow=T)
query <- matrix(c(594885.0,115435.0), ncol=2, byrow=T)
pip2d(Vertices = verts, Queries = query)  # result = -1
# contrary to -1 output of pip2d, plot shows point lies within triangle
plot(c(594400, 595000), c(115000, 117500), type="n")
polygon(verts, border="red")
points(x=query[,1], y=query[,2], col="blue")

Scott Waichler
Pacific Northwest National Laboratory
Richland, WA, USA




More information about the R-help mailing list