Learn R Programming

spatstat (version 1.55-0)

insertVertices: Insert New Vertices in a Linear Network

Description

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

Usage

insertVertices(L, …)

Arguments

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.

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.

Details

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.

See Also

as.lpp

Examples

Run this code
# NOT RUN {
   opa <- par(mfrow=c(1,3), mar=rep(0,4))
   simplenet

   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))
   L
   plot(L, main="")
   plot(vertices(L), add=TRUE)
   id <- attr(L, "id")
   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)
   par(opa)
# }

Run the code above in your browser using DataLab