Compute the nearest neighbour function of a point pattern on a linear network.
## S3 method for class 'lpp' nnfun(X, ..., k=1, value=c("index", "mark"))
A point pattern on a linear network
(object of class
Integer. The algorithm finds the
String (partially matched) specifying whether to return the
index of the neighbour (
Other arguments are ignored.
The (geodesic) nearest neighbour function of a
X on a linear network
tells us which point of
X is closest to
any given location.
X is a point pattern on a linear network
the nearest neighbour function of
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
measured by the shortest path. In other words the value of
is the identifier or serial number of the closest point of
nnfun.lpp is a method for the generic command
for the class
"lpp" of point patterns on a linear network.
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
in the form
v <- f(x,y), where
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.
f can take the arguments
x, y, seg, tp where
tp are the local
coordinates on the network.
The result of
f <- nnfun(X) also belongs to the class
It can be printed and plotted immediately as shown in the Examples.
It can be converted to a pixel image
function in the R language, with arguments
x,y and optional
It also belongs to the class
"linfun" which has methods
To compute the distance to the nearest neighbour, see
X <- runiflpp(3, simplenet) f <- nnfun(X) f plot(f) plot(nnfun(chicago, value="m"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.