thickenPolys | R Documentation |
Thicken a PolySet, where each unique (PID
, SID
)
describes a polygon.
thickenPolys (polys, tol = 1, filter = 3, keepOrig = TRUE,
close = TRUE)
polys |
PolySet to thicken. |
tol |
tolerance (in kilometres when |
filter |
minimum number of vertices per result polygon. |
keepOrig |
Boolean value; if |
close |
Boolean value; if |
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.
PolySet containing the thickened data. The function
recalculates the POS
values for each polygon.
Nicholas M. Boers, Staff Software Engineer
Jobber, Edmonton AB
Last modified Rd: 2013-04-10
thinPolys
.
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)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.