deg.dist: Function to compute the distance between two points - lat/lon...

Description Usage Arguments Value Author(s) Examples

Description

Compute the distance between two points

Usage

1
deg.dist(long1, lat1, long2, lat2)

Arguments

long1

Longitude at point of origin

lat1

Latitude at point of origin

long2

Longitude at destination point

lat2

Latitude at destination point

Value

A distance in kilometers

Author(s)

From fossil package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(PWS)
myDist = deg.dist(-84.3880556, 33.7488889, -83.3779358, 33.960948)
## The function is currently defined as
function (long1, lat1, long2, lat2) 
{
    rad <- pi/180
    a1 <- lat1 * rad
    a2 <- long1 * rad
    b1 <- lat2 * rad
    b2 <- long2 * rad
    dlon <- b2 - a2
    dlat <- b1 - a1
    a <- (sin(dlat/2))^2 + cos(a1) * cos(b1) * (sin(dlon/2))^2
    c <- 2 * atan2(sqrt(a), sqrt(1 - a))
    R <- 40041.47/(2 * pi)
    d <- R * c
    return(d)
  }

steviep42/PWS documentation built on May 30, 2019, 5:39 p.m.