insertVertices: Insert New Vertices in a Linear Network

View source: R/linnetsurgery.R

insertVerticesR Documentation

Insert New Vertices in a Linear Network


Adds new vertices to a linear network at specified locations along the network.


insertVertices(L, ...)



Linear network (object of class "linnet") or point pattern on a linear network (object of class "lpp").


Additional arguments passed to as.lpp specifying the positions of the new vertices along the network.


This function adds new vertices at locations along an existing linear 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 can be specified either as a point pattern (class "lpp" or "ppp") or using coordinate vectors x,y or seg,tp or x,y,seg,tp as explained in the help for as.lpp.

This function breaks the existing line segments of L into pieces at the locations specified by the coordinates seg,tp and creates new vertices at these locations.

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

See Also

addVertices to create new vertices at locations which are not yet on the network.

as.lpp, linnet, methods.linnet, joinVertices, thinNetwork.


   opa <- par(mfrow=c(1,3), mar=rep(0,4))

   plot(simplenet, main="")
   plot(vertices(simplenet), add=TRUE)

   # add two new vertices at specified local coordinates
   L <- insertVertices(simplenet, seg=c(3,7), tp=c(0.2, 0.5))
   plot(L, main="")
   plot(vertices(L), add=TRUE)
   id <- attr(L, "id")
   plot(vertices(L)[id], add=TRUE, pch=16)

   # add new vertices at three randomly-generated points
   X <- runiflpp(3, simplenet)
   LL <- insertVertices(simplenet, X)
   plot(LL, main="")
   plot(vertices(LL), add=TRUE)
   ii <- attr(LL, "id")
   plot(vertices(LL)[ii], add=TRUE, pch=16)

spatstat.linnet documentation built on March 18, 2022, 6:40 p.m.