Hello; Please coud you advise me of a simple way to select points (x,y coordinates) that fall within a polygon. I've got a set of polygons, each one defined by an arbitrary number of points, and several points inside each polygon. I know this is simple with a GIS, but I'd rather do it inside R. Thanks and best regards, Javier -----
<jgarcia <at> ija.csic.es> writes:> > Hello; > Please coud you advise me of a simple way to select points (x,y > coordinates) that fall within a polygon. > I've got a set of polygons, each one defined by an arbitrary number of > points, and several points inside each polygon. > I know this is simple with a GIS, but I'd rather do it inside R.If your data are geographical, please see ?"overlay-methods" in the sp package. You may also choose to follow up this question on the R-sig-geo list. There are also ways of doing this at a lower level (without creating sp objects first) in at least the splancs package, say if the data are not geographical. Roger> Thanks and best regards, > Javier > ----- > > ______________________________________________ > R-help <at> r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
On 28/01/2008, at 11:14 PM, jgarcia at ija.csic.es wrote:> Hello; > Please coud you advise me of a simple way to select points (x,y > coordinates) that fall within a polygon. > I've got a set of polygons, each one defined by an arbitrary number of > points, and several points inside each polygon. > I know this is simple with a GIS, but I'd rather do it inside R.You could convert the polygon to an owin object and use inside.owin() in the spatstat package. You could also use the undocumented spatstat function inside.xypolygon (). cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}