fixPOS: Fix the POS Column of a PolySet

View source: R/PBSmapping.r

fixPOSR Documentation

Fix the POS Column of a PolySet

Description

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

Usage

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, Staff Software Engineer
Jobber, Edmonton AB
Last modified Rd: 2013-04-10

See Also

closePolys, fixBound, isConvex, isIntersecting, PolySet.

Examples

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 Sept. 30, 2024, 9:21 a.m.