convDP | R Documentation |
Convert EventData/PolyData into a PolySet.
convDP (data, xColumns, yColumns)
data |
PolyData or EventData. |
xColumns |
vector of X-column names. |
yColumns |
vector of Y-column names. |
This function expects data
to contain several X- and Y-columns.
For example, consider data
with columns x1
, y1
,
x2
, and y2
. Suppose xColumns = c("x1", "x2")
and
yColumns = c("y1", "y2")
. The result will contain
nrow(data)
polygons. Each one will have two vertices,
(x1, y1)
and (x2, y2)
and POS
values 1 and 2,
respectively. If data
includes an SID
column, so will
the result.
If data
contains an EID
and not a PID
column,
the function uses the EID
s as PID
s.
If data
contains both PID
and EID
columns,
the function assumes it is PolyData and ignores the EID
column.
PolySet with the same PID
s as those given in data
. If
data
has an SID
column, the result will include it.
Nicholas M. Boers, Staff Software Engineer
Jobber, Edmonton AB
Last modified Rd: 2013-04-10
addPoints
,
plotPoints
.
local(envir=.PBSmapEnv,expr={
oldpar = par(no.readonly=TRUE)
#--- create sample PolyData
polyData <- data.frame(PID=c(1, 2, 3),
x1=c(1, 3, 5), y1=c(1, 3, 2),
x2=c(1, 4, 5), y2=c(2, 4, 1),
x3=c(2, 4, 6), y3=c(2, 3, 1))
#--- print PolyData
print(polyData)
#--- make a PolySet from PolyData
polys <- convDP(polyData,
xColumns=c("x1", "x2", "x3"),
yColumns=c("y1", "y2", "y3"))
#--- print and plot the PolySet
print(polys)
plotLines(polys, xlim=c(0,7), ylim=c(0,5), col=2)
par(oldpar)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.