GCdistance: Great circle distance

Description Usage Arguments Value Author(s) References Examples

View source: R/GCdistance.R

Description

Great circle or geodesic distance.

Usage

1
GCdistance(lat1,lon1,lat2,lon2)

Arguments

lat1

Latitude of points of origin.

lon1

Longitude of points of origin.

lat2

Latitude of points of destination.

lon2

Longitude of points of destination.

Value

Distance between origin and destination points in metres.

Author(s)

Javier G. Corripio

References

https://edwilliams.org/avform.htm,

http://mathworld.wolfram.com/GreatCircle.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
GCdistance(0,0,0,180)*2

# distance between the center of US states 
data(state)
ddd = matrix(nrow=50,ncol=50,dimnames=list(state.name,state.name))
for (i in 1:50){
	for (j in 1:50){
		distij = GCdistance(state.center$y[i],state.center$x[i],
			state.center$y[j],state.center$x[j])
		# round to miles
		ddd[i,j]=round(distij/1609.344,2)
	}
}
# format and print results for the 10 firsts states
as.dist(ddd[1:10,1:10])

insol documentation built on Feb. 10, 2021, 5:08 p.m.