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.
See Also
thinPolys.
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)
})
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/thickenPolys.Rd_%03d_medium.png", width=480, height=480)
> ### Name: thickenPolys
> ### Title: Thicken a PolySet of Polygons
> ### Aliases: thickenPolys
> ### Keywords: manip
>
> ### ** 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)
+ })
>
>
>
>
>
> dev.off()
null device
1
>