lineardisc: Compute Disc of Given Radius in Linear Network

View source: R/lineardisc.R

lineardiscR Documentation

Compute Disc of Given Radius in Linear Network

Description

Computes the ‘disc’ of given radius and centre in a linear network.

Usage

  lineardisc(L, x = locator(1), r, plotit = TRUE,
             cols=c("blue", "red","green"), add=TRUE)

  lineardisclength(L, x = locator(1), r)

  countends(L, x = locator(1), r, toler=NULL, internal=list())

Arguments

L

Linear network (object of class "linnet").

x

Location of centre of disc. Either a point pattern (object of class "ppp") containing exactly 1 point, or a numeric vector of length 2.

r

Radius of disc.

plotit

Logical. Whether to plot the disc.

add

Logical. If add=TRUE (the default), the disc will be plotted on the current plot frame. If add=FALSE, a new plot frame will be started, the entire network will be displayed, and then the disc will be plotted over this.

cols

Colours for plotting the disc. A numeric or character vector of length 3 specifying the colours of the disc centre, disc lines and disc endpoints respectively.

toler

Optional. Distance threshold for countends. See Details. There is a sensible default.

internal

Argument for internal use by the package.

Details

The ‘disc’ B(u,r) of centre x and radius r in a linear network L is the set of all points u in L such that the shortest path distance from x to u is less than or equal to r. This is a union of line segments contained in L.

The relative boundary of the disc B(u,r) is the set of points v such that the shortest path distance from x to u is equal to r.

The function lineardisc computes the disc of radius r and its relative boundary, optionally plots them, and returns them. The faster function lineardisclength computes only the total length of the disc, and countends computes only the number of endpoints of the disc.

Note that countends requires the linear network L to be given in the non-sparse matrix format (see the argument sparse in linnet or as.linnet) while lineardisc and lineardisclength accept both sparse and non-sparse formats.

The optional threshold toler is used to suppress numerical errors in countends. If the distance from u to a network vertex v is between r-toler and r+toler, the vertex will be treated as lying on the relative boundary.

Value

The value of lineardisc is a list with two entries:

lines

Line segment pattern (object of class "psp") representing the interior disc

endpoints

Point pattern (object of class "ppp") representing the relative boundary of the disc.

The value of lineardisclength is a single number giving the total length of the disc.

The value of countends is an integer giving the number of points in the relative boundary.

Author(s)

\wei

and \adrian

References

Ang, Q.W. (2010) Statistical methodology for events on a network. Master's thesis, School of Mathematics and Statistics, University of Western Australia.

Ang, Q.W., Baddeley, A. and Nair, G. (2012) Geometrically corrected second-order analysis of events on a linear network, with applications to ecology and criminology. Scandinavian Journal of Statistics 39, 591–617.

See Also

linnet

Examples

    # letter 'A' 
    v <- ppp(x=(-2):2, y=3*c(0,1,2,1,0), c(-3,3), c(-1,7))
    edg <- cbind(1:4, 2:5)
    edg <- rbind(edg, c(2,4))
    letterA <- linnet(v, edges=edg)
    plot(letterA)

   di <- lineardisc(letterA, c(0,3), 1.6)
   di

   # count the endpoints more efficiently
   countends(letterA, c(0,3), 1.6)
   # cross-check 
   npoints(di$endpoints)

   # measure the length more efficiently
   lineardisclength(letterA, c(0,3), 1.6)
   # cross-check
   sum(lengths_psp(di$lines))

spatstat.linnet documentation built on Nov. 2, 2023, 6:10 p.m.