Skip to contents

This function calculates the shortest arc distance matrix between two sets of points.

Usage

arcdistmat(
  points1,
  points2 = NULL,
  origin = c(0, 0, 0),
  output = "distance",
  radius = authRadius
)

Arguments

points1

(numeric) Matrix, XYZ or longitude-latitude coordinates of the first set of points.

points2

(numeric) Matrix, XYZ or longitude-latitude coordinates of the second set of points. Leave this empty if you want all the arc distances between a set of points

origin

(numeric) Vector, the center of the circle in XYZ coordinates (default is c(0,0,0)).

output

(character) The type of the output value. "distance" will give back the distance in the metric that was fed to the function in the coordinates or the radius. "deg" will output the the distance in degrees, "rad" will do so in radians.

radius

(numeric) The radius of the circle in case the input points have polar coordinates only. Unused when XYZ coordinates are entered. Defaults to the authalic radius of Earth ca. 6371.007km.

Value

A single numeric value.

Details

This function will create all possible shortest arc distances between points in the two sets, but not between the points within the sets. The function is useful for great circle distance calculations. For a symmetrical distance matrix leave the points2 argument empty.

Examples

g <- trigrid(c(4))
res <- arcdistmat(g@vertices)

rand<-rpsphere(500)
res2 <- arcdistmat(g@vertices, rand)