EVOLUTION-MANAGER
Edit File: in.out.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Which of a set of points lie within a polygon defined region</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for in.out {mgcv}"><tr><td>in.out {mgcv}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Which of a set of points lie within a polygon defined region</h2> <h3>Description</h3> <p>Tests whether each of a set of points lie within a region defined by one or more (possibly nested) polygons. Points count as ‘inside’ if they are interior to an odd number of polygons. </p> <h3>Usage</h3> <pre> in.out(bnd,x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>bnd</code></td> <td> <p>A two column matrix, the rows of which define the vertices of polygons defining the boundary of a region. Different polygons should be separated by an <code>NA</code> row, and the polygons are assumed closed.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>A two column matrix. Each row is a point to test for inclusion in the region defined by <code>bnd</code>.</p> </td></tr> </table> <h3>Details</h3> <p> The algorithm works by counting boundary crossings (using compiled C code). </p> <h3>Value</h3> <p>A logical vector of length <code>nrow(x)</code>. <code>TRUE</code> if the corresponding row of <code>x</code> is inside the boundary and <code>FALSE</code> otherwise. </p> <h3>Author(s)</h3> <p> Simon N. Wood <a href="mailto:simon.wood@r-project.org">simon.wood@r-project.org</a> </p> <h3>References</h3> <p><a href="http://www.maths.bris.ac.uk/~sw15190/">http://www.maths.bris.ac.uk/~sw15190/</a> </p> <h3>Examples</h3> <pre> library(mgcv) data(columb.polys) bnd <- columb.polys[[2]] plot(bnd,type="n") polygon(bnd) x <- seq(7.9,8.7,length=20) y <- seq(13.7,14.3,length=20) gr <- as.matrix(expand.grid(x,y)) inside <- in.out(bnd,gr) points(gr,col=as.numeric(inside)+1) </pre> <hr /><div style="text-align: center;">[Package <em>mgcv</em> version 1.8-28 <a href="00Index.html">Index</a>]</div> </body></html>