50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

spectralGP (version 1.3.3)

rdist.earth: Great circle distance matrix

Description

Given two sets of longitude/latitude locations computes the Great circle (geogrpahic) distance matrix among all pairings. This function and help file are copied from the fields library.

Usage

rdist.earth(loc1, loc2, miles = TRUE, R = NULL)

Arguments

loc1
Matrix of first set of lon/lat coordinates first column is the longitudes and second is the latitudes.
loc2
Matrix of second set of lon/lat coordinates first column is the longitudes and second is the latitudes. If missing x1 is used.
miles
If true distances are in statute miles if false distances in kilometers.
R
Radius to use for sphere to find spherical distances. If NULL the radius is either in miles or kilometers depending on the values of the miles argument. If R=1 then distances are of course in radians.

Value

The great circle distance matrix if nrow(x1)=m and nrow( x2)=n then the returned matrix will be mXn.

Details

Surprisingly this all done efficiently in S.

See Also

rdist, exp.earth.cov

Examples

Run this code
 lon.lat=cbind(runif(20,0,360),runif(20,-90,90))
 out<- rdist.earth (lon.lat)
#out is a 20X20 distance matrix	

Run the code above in your browser using DataLab