TrajInPolygon {trajr} | R Documentation |
Test whether each of the points in a trajectory lie inside a polygon
Description
Simply a wrapper around point.in.polygon
. The sp
package must be installed for this function to be called. sp
is not
automatically installed as a dependency of trajr.
Usage
TrajInPolygon(trj, boundary)
Arguments
trj |
Trajectory to test |
boundary |
A polygon defining the region to be tested against. Can be
any structure that |
Value
Integer array with a value for each point in the trajectory. Values are: 0: point is strictly exterior to boundary; 1: point is strictly interior to boundary; 2: point lies on the relative interior of an edge of boundary; 3: point is a vertex of boundary
See Also
Examples
# Square arena
boundary <- data.frame(x = c(-10, 10, 10, -10), y = c(-10, -10, 10, 10))
# Generate a random trajectory
set.seed(1)
trj <- TrajGenerate(n = 10, stepLength = 2, angularErrorSd = .15)
# Test which points lie inside the boundary
print(TrajInPolygon(trj, boundary))
## [1] 1 1 1 1 1 1 0 0 0 0 0
[Package trajr version 1.5.1 Index]