inside {fastshp} | R Documentation |
inside
returns indices of shapes that contain given points
inside(shp, x, y, clockwise = TRUE, all = FALSE)
shp |
shape object (as returned by |
x |
x coordinates of the points to match |
y |
y coordinates of the points to match |
clockwise |
logical: if |
all |
logical: if |
The matching uses bounding box as a first approximation and then
winding rule (due east) to determine whether the point is inside. If
more than one shape matches, the index of the first matching shape is
returned unless all=TRUE
is set in which case each entry is
a list of all matches. Points exactly on the boundary (as far as
possible by floating point arithmetics) are not considered
inside. Note that the shape cooridnates must be in R polygon format
(format="polygon"
in read.shp
) or have just one part,
otherwise parts will not be treated properly.
If all=FALSE
:
Integer vector of the same length as the number of points, each value
is either an index of the first matching shape or NA
if the
point is not inside of any shapes.
If all=TRUE
:
List of integer vectors with the indices of matching shapes (which
whill be empty if there is no match). There will be as many elements
in the list as there are points.
Holes are currently not considered by this method. There is a slower implementation using CGAL that treats holes properly.
Simon Urbanek