Learn R Programming

PBSmapping (version 2.74.1)

clipPolys: Clip a PolySet as Polygons or Polylines

Description

Clip a 'PolySet', where each unique ('PID', 'SID') describes a polygon or polyline.

Usage

clipPolys (polys, xlim, ylim, keepExtra = FALSE)

clipLines (polys, xlim, ylim, keepExtra = FALSE)

.clip(polys, xlim, ylim, isPolygons, keepExtra)

Value

'PolySet' containing the input data, with some points added or removed. A new column 'oldPOS' records the original 'POS'

value for each vertex.

Arguments

polys

data.frame -- 'PolySet' to clip

xlim

numeric -- range of X-coordinates

ylim

numeric -- range of Y-coordinates

keepExtra

logical -- if TRUE, try to carry forward any non-standard columns into the result

isPolygons

logical -- if TRUE, then PolySet contains polygons, else PolySet contains polylines

Author

Nicholas M. Boers, Software Engineer, Jobber, Edmonton AB

Maintainer: Rowan Haigh, Program Head -- Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
locus opus: Remote office, Vancouver BC
Last modified Rd: 2024-09-03

Details

For each discrete polygon, the function connects vertices 1 and N (does not connect vertices 1 and N for discrete polylines). It recalculates the 'POS' values for each vertex, saving the old values in a column named 'oldPOS'. For new vertices, it sets 'oldPOS' to NA.

See Also

In package PBSmapping:
addLines, addPolys, addStipples, PolySet

Examples

Run this code
local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- create a triangle that will be clipped
  polys <- data.frame(PID=rep(1, 3), POS=1:3, X=c(0,1,.5), Y=c(0,0,1))
  #--- clip the triangle in the X direction, and plot the results
  plotPolys(clipPolys(polys,xlim=c(0,.75),ylim=range(polys[,"Y"])),col=2)
  par(oldpar)
})

Run the code above in your browser using DataLab