nncross.sph | R Documentation |
Given two point patterns X
and Y
on a (subset of) a
sphere, finds the nearest neighbour in Y
of each point of X
.
nncrosssph(X, Y, rad=1)
X, Y |
Locations of points. Objects of class |
rad |
The radius of the sphere. |
Given two point patterns X
and Y
this function finds,
for each point of X
, the nearest point of Y
. This is
done using great circle distances.
The return value is a numeric, the i
th value of which is the
great circle distance from the i
th point in X
to the
nearest point in Y
.
Note that this function is not symmetric in X
and Y
. To
find the nearest neighbour in X
of each point in Y
,
where Y
is a point pattern, use nncross.sph(Y,X)
.
If X
is an object of class sp2
or
sp3
, then its radius is used in this calculation. If
X
is a matrix, and Y
is an object of class
sp2
or sp3
, then its radius is used in
this calculation. If both X
and Y
are objects of class
sp2
or sp3
, they must have the same radius
or an error will be generated.
Numeric containing the nearest neighbour distances for each point.
This function is the analogue for point processes on the sphere of the
function nncross
in spatstat, which is the
corresponding function for point processes in R^2. Hence
elements of the code for nncross.sph
and help page have been taken
from nncross
with the permission of
A. J. Baddeley. This enables the code to be highly efficient and give
corresponding output to, and for the information on this help page to
be consistent with that for the function nncross
.
It is hoped that this will minimise or remove any confusion for users
of both spatstat and spherstat.
Tom Lawrence <email: tjlawrence@bigpond.com>
nndistsph
(nearest neighbour distances for a single
sample), crossdistsph
(pairwise distances between two
samples), pairdistsph
(pairwise distances for a single
sample), gcdist
(great circle distance between two
points), bdist.sphwin
(boundary distances), nncross
sph <- sphwin(type="sphere") X <- rpoispp.sphwin(win=sph, lambda=1) Y <- rpoispp.sphwin(win=sph, lambda=1) nncrosssph(X, Y) Xmat <- rpoispp.sphwin(win=sph, lambda=1, as.sp=FALSE) Ymat <- rpoispp.sphwin(win=sph, lambda=1, as.sp=FALSE) nncrosssph(Xmat, Ymat, rad=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.