pointinpolygon | R Documentation |
Test whether each point lies inside a specified polygon.
pointinpolygon(P, A, eps, x0, y0)
P |
Spatial coordinates of the points to be tested.
A list of two vectors named |
A |
A single polygon, specified as a list of two vectors
named |
eps |
Spatial resolution for coordinates. |
x0 , y0 |
Spatial origin for coordinates. |
This is part of an interface to the polygon-clipping library
Clipper
written by Angus Johnson.
The argument A
represents a closed polygon.
It should be
a list containing two components x
and y
giving the coordinates of the vertices.
The last vertex should
not repeat the first vertex.
Calculations are performed in integer arithmetic
after subtracting x0,y0
from the coordinates,
dividing by eps
, and rounding to the nearest integer.
Thus, eps
is the effective spatial resolution.
The default values ensure reasonable accuracy.
An integer vector with one entry for each point in P
.
The result is 0 if the point lies outside A
,
1 if the point lies inside A
, and -1 if it lies on the
boundary.
Angus Johnson. Ported to R by Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
Clipper Website: http://www.angusj.com
Vatti, B. (1992) A generic solution to polygon clipping. Communications of the ACM 35 (7) 56–63. https://dl.acm.org/doi/10.1145/129902.129906
Agoston, M.K. (2005) Computer graphics and geometric modeling: implementation and algorithms. Springer-Verlag. http://books.google.com/books?q=vatti+clipping+agoston
polyclip
.
A <- list(x=1:10, y=c(1:5,5:1))
P <- list(x=4, y=2)
pointinpolygon(P, A)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.