rcosmo (version 1.1.2)

geoDist: Geodesic distance on the unit sphere

Description

Get geodesic distance between points on the unit sphere

Usage

geoDist(p1, p2, include.names = FALSE)

Arguments

p1

A data.frame with rows specifying numeric points located on the unit sphere. It should have columns labelled x,y,z for Cartesian or theta, phi for spherical colatitude and longitude respectively.

p2

Same as p1.

include.names

Boolean. If TRUE then the row and column names of the returned matrix will be taken from the points in p1 and p2 (see examples below).

Value

Let \(n\) denote the number of rows of p1 and let \(m\) denote the number of rows of p2. Then the returned object is an \(n\) by \(m\) matrix whose entry in position \(ij\) is the geodesic distance from the \(i\)th row of p1 to the \(j\)th row of p2.

Examples

Run this code
# NOT RUN {
p1 <- data.frame(diag(3))
colnames(p1) <- c("x", "y", "z")
p1
p2 <- data.frame(x=c(1,0), y=c(0,3/5), z=c(0,4/5))
p2
geoDist(p1, p2, include.names = FALSE)

# }

Run the code above in your browser using DataCamp Workspace