fixPOS: Fix the POS Column of a PolySet

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

View source: R/PBSmapping.r

Description

Fix the POS column of a PolySet by recalculating it using sequential integers.

Usage

1
fixPOS (polys, exteriorCCW = NA)

Arguments

polys

PolySet to fix.

exteriorCCW

Boolean value; if TRUE, orders exterior polygon vertices in a counter-clockwise direction. If FALSE, orders them in a clockwise direction. If NA, maintains their original order.

Details

This function recalculates the POS values of each (PID, SID) as either 1 to N or N to 1, depending on the order of POS (ascending or descending) in the input data. POS values in the input must be properly ordered (ascending or descending), but they may contain fractional values. For example, POS = 2.5 might correspond to a point manually added between POS = 2 and POS = 3. If exteriorCCW = NA, all other columns remain unchanged. Otherwise, it orders the X and Y columns according to exteriorCCW.

Value

PolySet with the same columns as the input, except for possible changes to the POS, X, and Y columns.

Author(s)

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

See Also

closePolys, fixBound, isConvex, isIntersecting, PolySet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
local(envir=.PBSmapEnv,expr={
  #--- create a PolySet with broken POS numbering
  polys <- data.frame(PID = c(rep(1, 10), rep(2, 10)),
    POS = c(seq(2, 10, length = 10), seq(10, 2, length = 10)),
    X = c(rep(1, 10), rep(1, 10)),
    Y = c(rep(1, 10), rep(1, 10)))
  #--- fix the POS numbering
  polys <- fixPOS(polys)
  #--- print the results
  print(polys)
})

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