crossdist.sph: Pairwise Distances

crossdist.sphR Documentation

Pairwise Distances

Description

Computes the distances between pairs of points on the sphere, taken from two different datasets

Usage

crossdistsph(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, default value 1. Only required when neither X nor Y are objects of class sp2 or sp3.

Details

Given two datasets X and Y (representing two point patterns on the same (subset of a) sphere) crossdist.sph computes the great circle distance from each point in the first dataset to each point in the second dataset, and returns a matrix containing these distances.

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

A matrix whose [i,j] entry is the distance from the i-th point in the first dataset to the j-th point in the second dataset.

Note

This function is the analogue for point processes on the sphere of the function crossdist in spatstat, which is the corresponding function for point processes in R^2. Hence elements of the code for crossdist.sph and help page have been taken from crossdist 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 crossdist. 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

nncrosssph (nearest neighbour distances between two samples), nndistsph (nearest neighbour distances), gcdist (great circle distance between two points), bdist.sphwin (boundary distances), crossdist

Examples

sph <- sphwin(type="sphere")
rps1 <- rpoispp.sphwin(win=sph, lambda=1)
rps2 <- rpoispp.sphwin(win=sph, lambda=1)
crossdistsph(X=rps1, Y=rps2)

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