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

nnfun.lpp

Nearest Neighbour Map on Linear Network


Description

Compute the nearest neighbour function of a point pattern on a linear network.

Usage

## S3 method for class 'lpp'
nnfun(X, ..., k=1, value=c("index", "mark"))

Arguments

X

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

k

Integer. The algorithm finds the kth nearest neighbour in X from any spatial location.

value

String (partially matched) specifying whether to return the index of the neighbour (value="index", the default) or the mark value of the neighbour (value="mark").

...

Other arguments are ignored.

Details

The (geodesic) nearest neighbour function of a point pattern X on a linear network L tells us which point of X is closest to any given location.

If X is a point pattern on a linear network L, the nearest neighbour function of X is the mathematical function f defined for any location s on the network by f(s) = i, where X[i] is the closest point of X to the location s measured by the shortest path. In other words the value of f(s) is the identifier or serial number of the closest point of X.

The command nnfun.lpp is a method for the generic command nnfun for the class "lpp" of point patterns on a linear network.

If X is a point pattern on a linear network, f <- nnfun(X) returns a function in the R language, with arguments x,y, ..., that represents the nearest neighbour function of X. Evaluating the function f in the form v <- f(x,y), where x and y are any numeric vectors of equal length containing coordinates of spatial locations, yields a vector of identifiers or serial numbers of the data points closest to these spatial locations. More efficiently f can take the arguments x, y, seg, tp where seg and tp are the local coordinates on the network.

The result of f <- nnfun(X) also belongs to the class "linfun". It can be printed and plotted immediately as shown in the Examples. It can be converted to a pixel image using as.linim.

Value

A function in the R language, with arguments x,y and optional arguments seg,tp. It also belongs to the class "linfun" which has methods for plot, print etc.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk

See Also

To compute the distance to the nearest neighbour, see distfun.lpp.

Examples

X <- runiflpp(3, simplenet)
   f <- nnfun(X)
   f
   plot(f)
   plot(nnfun(chicago, value="m"))

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.