gcdist: Great Circle Distances

View source: R/gcdist.R

gcdistR Documentation

Great Circle Distances

Description

Calculate the minimum great circle distance between points on a sphere

Usage

gcdist(x, y, rad = 1)
gcdistPaired(x, y, rad = 1)

Arguments

x,y

The locations of the two points for which the distance is to be calculated. Each must be a matrix with 2 columns (with location in spherical coordinates) or or 3 (location in Cartesian coordinates), or objects of class sp2 or sp3. Note x and y need not be in the same format.

rad

Optional. The radius of the sphere, default is 1.

Details

For any two points on a sphere, the shortest path (also on the sphere) is the minor arc of a great circle (that is, a circle that is concentric with the sphere, and is a subset of the sphere).

The function gcdist calculates the great circle distance between each pair of points in x and y, returning a matrix of size m * n where m is the number of points in x and n is the number of points in y.

The function gcdistPaired calculates the great circle distance between corresponding points in x and y (that is, between the ith point in x and the ith point in y for each index i), returning a numeric vector. The point patterns x and y should contain equal numbers of points.

Value

A numeric matrix or vector giving the minimum great circle distance between the given pairs of points.

Author(s)

Tom Lawrence <email:tjlawrence@bigpond.com>

See Also

nndistsph (nearest neighbour distances), pairdistsph (pairwise distances), bdist.sphwin (boundary distances) dist (methods for measuring distance in R^d)

Examples

x1 <- matrix(c(pi/2, 0), ncol=2)
y1 <- matrix(c(pi/2, pi/4), ncol=2)
gcdist(x=x1, y=y1)

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