Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

point.in.polygon

do point(s) fall in a given polygon?


Description

verifies for one or more points whether they fall in a given polygon

Usage

point.in.polygon(point.x, point.y, pol.x, pol.y, mode.checked=FALSE)

Arguments

point.x

numerical array of x-coordinates of points

point.y

numerical array of y-coordinates of points

pol.x

numerical array of x-coordinates of polygon

pol.y

numerical array of y-coordinates of polygon

mode.checked

default FALSE, used internally to save time when all the other argument are known to be of storage mode double

Value

integer array; values are: 0: point is strictly exterior to pol; 1: point is strictly interior to pol; 2: point lies on the relative interior of an edge of pol; 3: point is a vertex of pol.

References

Uses the C function InPoly(). InPoly is Copyright (c) 1998 by Joseph O'Rourke. It may be freely redistributed in its entirety provided that this copyright notice is not removed.

Examples

# open polygon:
point.in.polygon(1:10,1:10,c(3,5,5,3),c(3,3,5,5))
# closed polygon:
point.in.polygon(1:10,rep(4,10),c(3,5,5,3,3),c(3,3,5,5,3))

sp

Classes and Methods for Spatial Data

v1.4-5
GPL (>= 2)
Authors
Edzer Pebesma [aut, cre], Roger Bivand [aut], Barry Rowlingson [ctb], Virgilio Gomez-Rubio [ctb], Robert Hijmans [ctb], Michael Sumner [ctb], Don MacQueen [ctb], Jim Lemon [ctb], Finn Lindgren [ctb], Josh O'Brien [ctb], Joseph O'Rourke [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.