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

appendPolys

Append a Two-Column Matrix to a PolySet


Description

Append a two-column matrix to a PolySet, assigning PID and possibly SID values automatically or as specified in its arguments.

Usage

appendPolys (polys, mat, PID = NULL, SID = NULL, isHole = FALSE)

Arguments

polys

existing PolySet; if NULL, creates a new PolySet (required).

mat

two-column matrix to append (required).

PID

new polygon's PID.

SID

new polygon's SID.

isHole

Boolean value; if TRUE, mat represents a hole.

Details

If the PID argument is NULL, the appended polygon's PID will be one greater than the maximum within polys (if defined); otherwise, it will be 1.

If polys contains an SID column and the SID argument equals NULL, this function uses the next available SID for the corresponding PID.

If polys does not contain an SID column and the caller passes an SID argument, all existing polygons will receive an SID of 1. The new polygon's SID will match the SID argument.

If isHole = TRUE, the polygon's POS values will appropriately represent a hole (reverse order of POS).

If (PID, SID) already exists in the PolySet, the function will issue a warning and duplicate those identifiers.

Value

PolySet containing mat appended to polys. The function retains attributes from polys.

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 two simple matrices
  a <- matrix(data=c(0,0,1,0,1,1,0,1),ncol=2,byrow=TRUE);
  b <- matrix(data=c(2,2,3,2,3,3,2,3), ncol=2,byrow=TRUE);
  #--- build a PolySet from them
  polys <- appendPolys(NULL, a);
  polys <- appendPolys(polys, b);
  #--- print the result
  print (polys);
})

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.