Learn R Programming

HRW (version 1.0-6)

pointsInPoly: Points inside/outside polygon determination

Description

Determination of whether each member of a set of bivariate points are inside a polygon.

Usage

pointsInPoly(pointsCoords,polygon)

Value

A Boolean array with length equal to the number of rows in `pointsCoords' corresponding to whether or not each of the corresponding points in 'pointCoords' are inside 'polygon'.

Arguments

pointsCoords

two-column matrix with each row specifying the (x,y) coordinates of a point.

polygon

two-column matrix with each row specifying the (x,y) coordinates of a vertex of a polygon.

Author

M.P. Wand matt.wand@uts.edu.au

Details

Geometric results are used to determine whether each of a set of bivariate points is inside or outside a polygon. A Boolean vector of indicators of whether or not each point is inside the polygon is returned.

See Also

createBoundary

Examples

Run this code
library(HRW)
myPolygon <- rbind(c(1,9),c(8,8),c(9,3),c(3,2),c(1,9))/10
plot(0:1,0:1,type = "n") ; lines(myPolygon)
xyMat <- cbind(runif(10),runif(10))
inPoly <- pointsInPoly(xyMat,myPolygon) ; print(inPoly)
points(xyMat[,1],xyMat[,2],col = as.numeric(inPoly) + 2)

Run the code above in your browser using DataLab