Learn R Programming

spTimer (version 0.02)

spT.geodist: Geodetic/geodesic Distance

Description

This geodetic distance provides the distance between the locations in Kilometers (k.m.) and Miles, using spherical law of Cosines.

Usage

spT.geodist(Lon, Lat, KM = TRUE)

spT.geo.dist(point1, point2)
spT.geo_dist(points)

Arguments

Lon
The longitude position.
Lat
The latitude position.
KM
A logical value, if 'TRUE' then output is in `kilometers', otherwise in `miles'.
point1
In the form of (longitude, latitude) position.
point2
In the form of (longitude, latitude) position.
points
In the form of points 1:(longitude, latitude) 2:(longitude, latitude) positions.

Details

spT.geodist is used to get geodetic distance in both miles and kilometers. spT.geo.dist is only used to get geodetic distance in kilometers with a different format. spT.geo_dist is only used to get geodetic distance in kilometers with a different format.

See Also

NYsite, NYdata, spT.grid.coords.

Examples

Run this code
##

# Load 29 ozone monitoring locations of New York.

data(NYsite)	
head(NYsite)	

# Find the geodetic distance in km

spT.geodist(Lon=NYsite$Longitude, Lat=NYsite$Latitude, KM=TRUE)
   
# Find the geodetic distance in miles

spT.geodist(Lon=NYsite$Longitude, Lat=NYsite$Latitude, KM=FALSE)

##

# using spT.geo.dist

point1<-c(-73.757,42.681)
point2<-c(-73.881,40.866)
spT.geo.dist(point1,point2)

# using spT.geo_dist

points<-c(point1,point2)
spT.geo_dist(points)

##

Run the code above in your browser using DataLab