findCells: Find Grid Cells that Contain Events

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Find the grid cells in a PolySet that contain events specified in EventData. Similar to findPolys, except this function requires a PolySet resulting from makeGrid. This restriction allows this function to calculate the result with greater efficiency.

Usage

1
findCells (events, polys, includeBdry=NULL)

Arguments

events

EventData to use.

polys

PolySet to use.

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). The Boolean (0,1) 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 (i.e., on two or more boundaries). Thus, the same EID can occur more than once in the output.

If an event happens to lie at the boundary intersection of four (or two) grid cells then one EID will be associated with four (or two) grid cells. 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 grid cell (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

findPolys, makeGrid, combineEvents, locateEvents, locatePolys, LocationSet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- create some EventData: points in a diagonal line
  events <- data.frame(EID=1:11, X=seq(0, 2, length=11),
     Y=seq(0, 2, length=11))
  events <- as.EventData(events, projection=1);
  #--- create a PolySet (a grid)
  polys <- makeGrid (x=seq(0, 2, by=0.50), y=seq(0, 2, by=0.50), 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 findCells and print the results
  fc <- findCells(events, polys)
  fc <- fc[order(fc$EID, fc$PID, fc$SID), ]
  fc$label <- paste(fc$PID, fc$SID, sep=", ")
  print (fc)
  #--- add labels to the graph
  addLabels(as.PolyData(fc[!duplicated(paste(fc$PID,fc$SID)), ],
    projection=1), placement="CENTROID", 
    polys=as.PolySet(polys, projection=1), col=4)
  par(oldpar)
})

PBSmapping documentation built on Jan. 15, 2021, 3:41 p.m.