I have a large set of points (latitude and longitude) constrained by a complex polygon. However some of the points are not within the bounds of the polygon, and I would like to subset these points from the original data frame (not the ppp object, described below).
#Simple example of a polygon and points.
ex.poly <- data.frame(x=c(0,5,5,2.5,0), y=c(0,0,5,2.5,5))
df <- data.frame(x=c(0.5, 2.5, 4.5, 2.5), y=c(4,1,4, 4))
bound <- owin(poly=data.frame(x=ex.poly$x, y=ex.poly$y))
test.ppp <- ppp(x=df$x, y=df$y, window=bound)
#plotting example, to show the one out of the bound owin object
plot(bound)
points(df$x, df$y)
The error message 1 point was rejected as lying outside the specified window
comes up, as expected. How would I subset the original dataframe df
to find out which point(s) is rejected?