addVertices {spatstat.linnet} | R Documentation |
Add New Vertices to a Linear Network
Description
Adds new vertices to a linear network at specified locations outside the network.
Usage
addVertices(L, X, join=NULL, joinmarks=NULL)
Arguments
L |
Existing linear network (object of class |
X |
Point pattern (object of class |
join |
Optional information specifying how to join the new vertices
|
joinmarks |
Optional vector or data frame of marks associated with the
new edges specified by |
Details
This function adds new vertices to an existing
linear network L
, at specified locations X
outside the network.
The argument L
can be either a linear network (class
"linnet"
) or some other object that includes a linear network.
The new vertex locations are points outside the network,
specified as a point pattern X
(object of class "ppp"
).
The argument join
specifies how to join the new vertices
to the existing network.
-
If
join=NULL
(the default), the new vertices are simply added to the list of network vertices without being joined to the rest of the network. -
If
join
is a vector of integers, then these are taken to be indices of existing vertices ofL
in the order given inV = vertices(L)
. Then each new vertexX[i]
will be joined to an existing vertexV[j]
wherej = join[i]
. Each new vertex is joined to exactly one existing vertex. -
If
join="vertices"
then each new vertexX[i]
is joined to the nearest existing vertexV[j]
. Each new vertex is joined to exactly one existing vertex. -
If
join="nearest"
then each new vertex is projected to the nearest location along on the network; these locations are inserted as new vertices ofL
; and then each vertexX[i]
is joined to the corresponding projected point. Each new vertex is joined to exactly one newly-inserted vertex. -
If
join
is a point pattern on a network (class"lpp"
), it must be defined on the same network asL
and it must consist of the same number of points asX
. The points ofjoin
will be inserted as new vertices ofL
, and then each vertexX[i]
is joined to the corresponding pointjoin[i]
. Each new vertex is joined to exactly one newly-inserted vertex.
The result is the modified object, with an attribute "id"
such that
the i
th added vertex has become the
id[i]
th vertex of the new network.
Value
An object of the same class as L
representing the result of
adding the new vertices.
The result also has an attribute "id"
as described in Details.
Author(s)
Adrian Baddeley
See Also
insertVertices
to insert vertices along an existing network.
as.lpp
,
linnet
,
methods.linnet
,
joinVertices
,
thinNetwork
.
Examples
opa <- par(mfrow=c(1,3))
L <- simplenet
X <- runifpoint(20, Window(simplenet))
plot(L)
plot(X, add=TRUE, cols="green", pch=16, cex=2)
plot(addVertices(L, X, "nearest"), col="red")
plot(L, add=TRUE, col="grey", lwd=3)
plot(X, add=TRUE, cols="green", pch=16, cex=2)
plot(addVertices(L, X, "vertices"), col="red")
plot(L, add=TRUE, col="grey", lwd=3)
plot(X, add=TRUE, cols="green", pch=16, cex=2)
par(opa)