Learn R Programming

geo (version 1.4-3)

arcdist: Geographical distance computations

Description

Computes distances between lat/lon data points.

Usage

arcdist(lat, lon, lat1 = NULL, lon1 = NULL, scale = "nmi")

Arguments

lat
Latitude of first coordinate or list with lat, lon of first coordinate.
lon
Longitude of first coordinate or list with lat, lon of second coordinate.
lat1,lon1
If lat and lon are vectors of lat,lon positions, then lat1 and lon1 must be given as the second set of positions.
scale
nmi returns value in nautical miles, any other value in kilometers

Value

A single vector of distances between pairs of points is returned

See Also

geoplot, geotext, selpos,

Examples

Run this code
pos1 <- list(lat = c(65, 66), lon = c(-19, -20))
  pos2 <- list(lat = c(64, 65), lon = c(-19, -20))
  dists <- arcdist(pos1, pos2)         # pos1 and pos2 are lists of coordinates.
  lat <- c(65, 66)
  lon <- c(-19, -20)
  lat1 <- c(64, 65)
  lon1 <- c(-19, -20)
  dists <- arcdist(lat, lon, lat1, lon1) # Input in vector format.

Run the code above in your browser using DataLab