nncross.sph: Nearest Neighbour Distances Between Two Point Patterns on the...

nncross.sphR Documentation

Nearest Neighbour Distances Between Two Point Patterns on the Sphere

Description

Given two point patterns X and Y on a (subset of) a sphere, finds the nearest neighbour in Y of each point of X.

Usage

nncrosssph(X, Y, rad=1)

Arguments

X, Y

Locations of points. Objects of class sp2 or sp3; 2 column matrices, with locations in spherical coordinates; or 3 column matrices, with locations in Cartesian coordinates. X and Y need not be given in the same format.

rad

The radius of the sphere.

Details

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 ith value of which is the great circle distance from the ith 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.

Value

Numeric containing the nearest neighbour distances for each point.

Note

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.

Author(s)

Tom Lawrence <email: tjlawrence@bigpond.com>

See Also

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

Examples

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)

baddstats/spherstat documentation built on Feb. 6, 2023, 1:45 a.m.