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

combineEvents

Combine Measurements of Events


Description

Combine measurements associated with events that occur in the same polygon.

Usage

combineEvents (events, locs, FUN, ..., bdryOK = TRUE)

Arguments

events

EventData with at least four columns (EID, X, Y, Z).

locs

LocationSet usually resulting from a call to findPolys.

FUN

a function that produces a scalar from a vector (e.g., mean, sum).

...

optional arguments for FUN.

bdryOK

Boolean value; if TRUE, include boundary points.

Details

This function combines measurements associated with events that occur in the same polygon. Each event (EID) has a corresponding measurement Z. The locs data frame (usually output from findPolys) places events within polygons. Thus, each polygon (PID, SID) determines a set of events within it, and a corresponding vector of measurements Zv. The function returns FUN(Zv), a summary of measurements within each polygon.

Value

PolyData with columns PID, SID (if in locs), and Z.

Author(s)

Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Last modified Rd: 2013-04-10

See Also

Examples

local(envir=.PBSmapEnv,expr={
  #--- create an EventData data frame: let each event have Z = 1
  events <- data.frame(EID=1:10, X=1:10, Y=1:10, Z=rep(1, 10))
  #--- example output from findPolys where 1 event occurred in the first
  #--- polygon, 3 in the second, and 6 in the third
  locs <- data.frame(EID=1:10,PID=c(rep(1,1),rep(2,3),rep(3,6)),Bdry=rep(0,10))
  #--- sum the Z column of the events in each polygon, and print the result
  print(combineEvents(events=events, locs=locs, FUN=sum))
})

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.