calcSummary: Apply Functions to Polygons in a PolySet

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

View source: R/PBSmapping.r

Description

Apply functions to polygons in a PolySet.

Usage

1
calcSummary (polys, rollup = 3, FUN, ...)

Arguments

polys

PolySet to use.

rollup

level of detail in the results; 1 = PIDs only, by removing the SID column, and then passing each PID into FUN, 2 = outer contours only, by making hole SIDs equal to their parent's SID, and then passing each (PID, SID) into FUN, and 3 = no roll-up.

FUN

the function to apply; it must accept a vector and return a vector or scalar.

...

optional arguments for FUN.

Details

If rollup equals 1, the results contain an entry for each unique PID only. When it equals 2, they contain entries for outer contours only. Finally, setting it to 3 prevents roll-up, and they contain an entry for each unique (PID, SID).

Value

PolyData with columns PID, SID (may be missing), X, and Y. If FUN returns a vector of length greater than 1 (say n), names the columns X1, X2, ..., Xn and Y1, Y2, ..., Yn.

Author(s)

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

See Also

calcArea, calcCentroid, calcConvexHull, calcLength, calcMidRange, combineEvents, findPolys, locateEvents, locatePolys, makeGrid, makeProps.

Examples

1
2
3
4
5
6
7
8
local(envir=.PBSmapEnv,expr={
  #--- load the data (if using R)
  if (!is.null(version$language) && (version$language=="R"))
    data(nepacLL,envir=.PBSmapEnv)
  #--- calculate and print the centroids for several polygons
  print(calcSummary(nepacLL[is.element(nepacLL$PID,c(33,39,47)),],
    rollup=3, FUN=mean))
})

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