R: Add New Vertices to a Linear Network

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 `"linnet"`) or point pattern on a linear network (object of class `"lpp"`).
`X` | Point pattern (object of class `"ppp"`) specifying the new vertices.
`join` | Optional information specifying how to join the new vertices `X` to the existing network. See Details. 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.
`joinmarks` | Optional vector or data frame of marks associated with the new edges specified by `join`.

### 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 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 `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)

[Package spatstat.linnet version 2.3-1 Index]