View source: R/linnetsurgery.R
| addVertices | R Documentation |
Adds new vertices to a linear network at specified locations outside the network.
addVertices(L, X, join=NULL, joinmarks=NULL)
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 |
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 of L in the order given
in V = vertices(L). Then each new vertex X[i] will be
joined to an existing vertex V[j] where j = join[i].
Each new vertex is joined to exactly one existing vertex.
If join="vertices" then each new vertex X[i] is joined
to the nearest existing vertex V[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 of L; and then each vertex X[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 as L and it must
consist of the same number of points as X. The points of
join will be inserted as new vertices of L,
and then each vertex X[i] is joined to the corresponding
point join[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 ith added vertex has become the
id[i]th vertex of the new network.
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.
Adrian Baddeley
insertVertices to insert vertices along an existing network.
as.lpp,
linnet,
methods.linnet,
joinVertices,
thinNetwork.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.