Last data update: 2014.03.03

R: Fix the Boundary Points of a PolySet
fixBoundR Documentation

Fix the Boundary Points of a PolySet

Description

The ranges of a PolySet's X and Y columns define its boundary. This function fixes a PolySet's vertices by moving vertices near a boundary to the actual boundary.

Usage

fixBound (polys, tol)

Arguments

polys

PolySet to fix.

tol

vector (length 1 or 2) specifying a percentage of the ranges to use in defining near to a boundary. If tol has two elements, the first specifies the tolerance for the x-axis and the second the y-axis. If it has only one element, the function uses the same tolerance for both axes.

Details

When moving vertices to a boundary, the function moves them strictly horizontally or vertically, as appropriate.

Value

PolySet identical to the input, except for possible changes in the X and Y columns.

See Also

closePolys, fixPOS, isConvex, isIntersecting, PolySet.

Examples

local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- set up a long horizontal and long vertical line to extend the plot's
  #--- limits, and then try fixing the bounds of a line in the top-left
  #--- corner and a line in the bottom-right corner
  polys <- data.frame(PID=c(1, 1, 2, 2,  3, 3, 4, 4),
    POS=c(1, 2, 1, 2,  1, 2, 1, 2),
    X = c(0, 10, 5, 5, 0.1, 4.9, 5.1, 9.9),
    Y = c(5, 5, 0, 10, 5.1, 9.9, 0.1, 4.9))
  polys <- fixBound(polys, tol=0.0100001)
  plotLines(polys)
  par(oldpar)
})

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(PBSmapping)

-----------------------------------------------------------
PBS Mapping 2.69.76 -- Copyright (C) 2003-2016 Fisheries and Oceans Canada

PBS Mapping comes with ABSOLUTELY NO WARRANTY;
for details see the file COPYING.
This is free software, and you are welcome to redistribute
it under certain conditions, as outlined in the above file.

A complete user guide 'PBSmapping-UG.pdf' is located at 
/home/ddbj/local/lib64/R/library/PBSmapping/doc/PBSmapping-UG.pdf

Packaged on 2015-04-23
Pacific Biological Station, Nanaimo

All available PBS packages can be found at
http://code.google.com/p/pbs-software/

To see demos, type '.PBSfigs()'.
-----------------------------------------------------------


> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/PBSmapping/fixBound.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fixBound
> ### Title: Fix the Boundary Points of a PolySet
> ### Aliases: fixBound
> ### Keywords: manip
> 
> ### ** Examples
> 
> local(envir=.PBSmapEnv,expr={
+   oldpar = par(no.readonly=TRUE)
+   #--- set up a long horizontal and long vertical line to extend the plot's
+   #--- limits, and then try fixing the bounds of a line in the top-left
+   #--- corner and a line in the bottom-right corner
+   polys <- data.frame(PID=c(1, 1, 2, 2,  3, 3, 4, 4),
+     POS=c(1, 2, 1, 2,  1, 2, 1, 2),
+     X = c(0, 10, 5, 5, 0.1, 4.9, 5.1, 9.9),
+     Y = c(5, 5, 0, 10, 5.1, 9.9, 0.1, 4.9))
+   polys <- fixBound(polys, tol=0.0100001)
+   plotLines(polys)
+   par(oldpar)
+ })
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>