View source: R/pointsInPolygon.R
pointsInPolygon | R Documentation |
For a given matrix of points coordinates, pointsInPolygon
returns a
logical vector stating whether or not these points are inside a specific
polygon whose coordinate as passed as an argument.
pointsInPolygon(points, polygon)
points |
a matrix of coordinates of points to be tested. |
polygon |
a two-columns matrix including the coordinate of the polygon. |
Implements the Ray-casting algorithm.
https://rosettacode.org/wiki/Ray-casting_algorithm#C
mat <- matrix(10*runif(100), 50) res <- pointsInPolygon(mat, cbind(c(4,8,8,4),c(4,4,8,8))) # Visual assessment plot0(c(0,10), c(0,10)) polygon(c(4,8,8,4),c(4,4,8,8)) graphics::points(mat[,1], mat[,2], col=res+1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.