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

findPolys

Find Polygons that Contain Events


Description

Find the polygons in a PolySet that contain events specified in EventData.

Usage

findPolys (events, polys, maxRows = 1e+05, includeBdry=NULL)

Arguments

events

EventData to use.

polys

PolySet to use.

maxRows

estimated maximum number of rows in the output LocationSet.

includeBdry

numeric: determines how points on boundaries are handled:
if NULL then report all points on polygon boundaries (default behaviour);
if 0 then exclude all points on polygon boundaries;
if 1 then report only the first (lowest PID/SID) polygon boundary;
if 2,...,n then report the last (highest PID/SID) polygon boundary.

Details

The resulting data frame, a LocationSet, contains the columns EID, PID, SID (if in polys), and Bdry, where an event (EID) occurs in a polygon (PID, SID) and SID does not correspond to an inner boundary. The Boolean variable Bdry indicates whether an event lies on a polygon's edge. Note that if an event lies properly outside of all the polygons, then a record with (EID, PID, SID) does not occur in the output. It may happen, however, that an event occurs in multiple polygons. Thus, the same EID can occur more than once in the output.

If an event happens to lie at the boundary intersection of two or more polygons then one EID will be associated with two or more polygons. A user can choose to manipulate this result by setting the argument includeBdry to a numeric value that constrains the association of a boundary event to 0 or 1 polygon (see argument description above).

Value

LocationSet that links events with polygons.

Author(s)

Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Last modified Rd: 2014-12-15

See Also

Examples

local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- create some EventData: a column of points at X = 0.5
  events <- data.frame(EID=1:10, X=.5, Y=seq(0, 2, length=10))
  events <- as.EventData(events, projection=1)
  #--- create a PolySet: two squares with the second above the first
  polys <- data.frame(PID=c(rep(1, 4), rep(2, 4)), POS=c(1:4, 1:4),
    X=c(0, 1, 1, 0, 0, 1, 1, 0),
    Y=c(0, 0, 1, 1, 1, 1, 2, 2))
  polys <- as.PolySet(polys, projection=1)
  #--- show a picture
  plotPolys(polys, xlim=range(polys$X)+c(-0.1, 0.1),
    ylim=range(polys$Y)+c(-0.1, 0.1), projection=1);
  addPoints(events, col=2);
  #--- run findPolys and print the results
  print(findPolys(events, polys))
  par(oldpar)
})

PBSmapping

Mapping Fisheries Data and Spatial Analysis Tools

v2.73.0
GPL (>= 2)
Authors
Jon T. Schnute [aut], Nicholas Boers [aut], Rowan Haigh [aut, cre], Alex Couture-Beil [ctb], Denis Chabot [ctb], Chris Grandin [ctb], Angus Johnson [ctb], Paul Wessel [ctb], Franklin Antonio [ctb], Nicholas J. Lewin-Koh [ctb], Roger Bivand [ctb]
Initial release
2021-01-12

We don't support your browser anymore

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