Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

thinNetwork

Remove Vertices or Segments from a Linear Network


Description

Delete some vertices and/or segments from a linear network or related object.

Usage

thinNetwork(X, retainvertices, retainedges)

Arguments

X

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

retainvertices

Optional. Subset index specifying which vertices should be retained (not deleted).

retainedges

Optional. Subset index specifying which edges (segments) should be retained (not deleted).

Details

This function deletes some of the vertices and edges (segments) in the linear network.

The arguments retainvertices and retainedges can be any kind of subset index: a vector of positive integers specifying which vertices/edges should be retained; a vector of negative integers specifying which vertices/edges should be deleted; or a logical vector specifying whether each vertex/edge should be retained (TRUE) or deleted (FALSE).

Vertices are indexed in the same sequence as in vertices(as.linnet(X)). Segments are indexed in the same sequence as in as.psp(as.linnet(X)).

The argument retainedges has higher precedence than retainvertices in the sense that:

  • If retainedges is given, then any vertex which is an endpoint of a retained edge will also be retained.

  • If retainvertices is given and retainedges is missing, then any segment joining two retained vertices will also be retained.

  • Thus, when both retainvertices and retainedges are given, it is possible that more vertices will be retained than those specified by retainvertices.

After the network has been altered, other consequential changes will occur, including renumbering of the segments and vertices. If X is a point pattern on a linear network, then data points will be deleted if they lie on a deleted edge.

Value

An object of the same kind as X.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Suman Rakshit.

See Also

linnet to make a network;

connected.linnet to extract connected components.

Examples

L <- simplenet
   plot(L, main="thinNetwork(L, retainedges=c(-3, -5))")
   text(midpoints.psp(as.psp(L)), labels=1:nsegments(L), pos=3)
   Lsub <- thinNetwork(L, retainedges=c(-3, -5))
   plot(Lsub, add=TRUE, col="blue", lwd=2)

spatstat.linnet

Linear Networks Functionality of the 'spatstat' Family

v2.1-1
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Ottmar Cronie [ctb], Tilman Davies [ctb], Greg McSwiggan [ctb], Suman Rakshit [ctb]
Initial release
2021-03-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.