[R] Filling polygons with points

Andy Bunn abunn at whrc.org
Thu Oct 14 16:24:23 CEST 2004


> I made a quick search and was unable to find a general implementation
> of the "interior" function for an arbitrary polygon; I'm a bit
> surprised about that.  Hopefully someone else can point to one,
> otherwise please write one, and document it and contribute it to R.
> It's a relatively standard algorithm, and would be useful.

A good place to start might be with the pip function in splancs. That should
do it with a little fussing, I think.

require(splancs)
data(bodmin)
pts <- gen(bodmin$poly,5000)
pts.inside <- pip(pts, bodmin$poly)
plot(bodmin$poly, asp=1, type="n")
pointmap(pts.inside, add=TRUE)
polymap(bodmin$poly, add=TRUE)

-Andy




More information about the R-help mailing list