Florian Nigsch
2006-Apr-26 17:13 UTC
[R] Polygon-like interactive selection of plotted points
[Please CC me for all replies, since I am not currently subscribed to the list.] Hi all, I have the following problem/question: Imagine you have a two- dimensional plot, and you want to select a number of points, around which you could draw a polygon. The points of the polygon are defined by clicking in the graphics window (locator()/identify()), all points inside the polygon are returned as an object. Is something like this already implemented? Thanks a lot in advance, Florian
Marc Schwartz (via MN)
2006-Apr-26 18:25 UTC
[R] Polygon-like interactive selection of plotted points
On Wed, 2006-04-26 at 18:13 +0100, Florian Nigsch wrote:> [Please CC me for all replies, since I am not currently subscribed to > the list.] > > Hi all, > > I have the following problem/question: Imagine you have a two- > dimensional plot, and you want to select a number of points, around > which you could draw a polygon. The points of the polygon are defined > by clicking in the graphics window (locator()/identify()), all points > inside the polygon are returned as an object. > > Is something like this already implemented? > > Thanks a lot in advance, > > FlorianI don't know if anyone has created a single function do to this (though it is always possible). However, using: RSiteSearch("points inside polygon") brings up several function hits that, if put together with the above interactive functions, could be used to do what you wish. That is, input the matrix of x,y coords of the interactively selected polygon and the x,y coords of the underlying points set to return the points inside or outside the polygon boundaries. Just as an FYI, you might also want to look at ?chull, which is in the base R distribution and returns the set of points on the convex hull of the underlying point set. This is to some extent, the inverse of what you wish to do. HTH, Marc Schwartz