## S3 method for class 'psp':
nndist(X, \dots, k=1, method="Fortran")
"psp"
).k
th nearest neighbour."Fortran"
and "interpreted"
.
Usually not specified. If k = 1
(the default), the return value is a
numeric vector v
such that v[i]
is the
nearest neighbour distance for the i
th segment.
If k
is a single integer, then the return value is a
numeric vector v
such that v[i]
is the
k
th nearest neighbour distance for the
i
th segment.
If k
is a vector, then the return value is a
matrix m
such that m[i,j]
is the
k[j]
th nearest neighbour distance for the
i
th segment.
nndist
for the class "psp"
. If k=1
, this function computes the distance from each line segment
to the nearest other line segment in X
.
In general it computes the distance from each line segment to the
k
th nearest other line segment.
The argument k
can also be a vector, and this computation will
be performed for each value of k
.
Distances are calculated using the Hausdorff metric. The Hausdorff distance between two line segments is the maximum distance from any point on one of the segments to the nearest point on the other segment.
If there are fewer than max(k)+1
line segments in the pattern,
some of the nearest neighbour distances will be infinite (Inf
).
The argument method
is not normally used. It is
retained only for checking the validity of the software.
If method = "interpreted"
then the distances are
computed using interpreted R code only. If method="Fortran"
(the default) then Fortran code is used. The Fortran code is somewhat faster.
nndist
,
nndist.ppp
L <- psp(runif(10), runif(10), runif(10), runif(10), owin())
D <- nndist(L)
D <- nndist(L, k=1:3)
Run the code above in your browser using DataLab