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

thickenPolys

Thicken a PolySet of Polygons


Description

Thicken a PolySet, where each unique (PID, SID) describes a polygon.

Usage

thickenPolys (polys, tol = 1, filter = 3, keepOrig = TRUE,
              close = TRUE)

Arguments

polys

PolySet to thicken.

tol

tolerance (in kilometres when proj is "LL" and "UTM"; otherwise, same units as polys).

filter

minimum number of vertices per result polygon.

keepOrig

Boolean value; if TRUE, keep the original points in the PolySet.

close

Boolean value; if TRUE, create intermediate vertices between each polygon's last and first vertex, if necessary.

Details

This function thickens each polygon within polys according to the input arguments.

If keepOrig = TRUE, all of the original vertices appear in the result. It calculates the distance between two sequential original vertices, and if that distance exceeds tol, it adds a sufficient number of vertices spaced evenly between the two original vertices so that the distance between vertices no longer exceeds tol. If close = TRUE, it adds intermediate vertices between the last and first vertices when necessary.

If keepOrig = FALSE, only the first vertex of each polygon is guaranteed to appear in the results. From this first vertex, the algorithm walks the polygon summing the distance between vertices. When this cumulative distance exceeds tol, it adds a vertex on the line segment under inspection. After doing so, it resets the distance sum, and walks the polygon from this new vertex. If close = TRUE, it will walk the line segment from the last vertex to the first.

Value

PolySet containing the thickened data. The function recalculates the POS values for each polygon.

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={
  oldpar = par(no.readonly=TRUE)
  #--- load the data (if using R)
  if (!is.null(version$language) && (version$language=="R"))
    data(nepacLL,envir=.PBSmapEnv)
  #--- plot Vancouver Island
  plotMap(nepacLL[nepacLL$PID == 33, ])
  #--- calculate a thickened version using a 30 kilometres tolerance,
  #--- without keeping the original points
  p <- thickenPolys(nepacLL[nepacLL$PID == 33, ], tol = 30, keepOrig = FALSE)
  #--- convert the PolySet to EventData by dropping the PID column and
  #--- renaming POS to EID
  p <- p[-1]; names(p)[1] <- "EID"
  #--- convert the now invalid PolySet into a data frame, and then into
  #--- EventData
  p <- as.EventData(as.data.frame(p), projection="LL")
  #--- plot the results
  addPoints(p, col=2, pch=19)
  par(oldpar)
})

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.