Learn R Programming

prabclus (version 2.2-2)

coord2dist: Geographical coordinates to distances

Description

Computes geographical distances from geographical coordinates

Usage

coord2dist(file=NULL, coordmatrix=NULL, cut=NULL,
                       file.format="degminsec",
                       output.dist=FALSE, radius=6378.137,
              fp=1/298.257223563, neighbors=FALSE)

Arguments

file
string. A filename for the coordinate file. The file should have 2, 4 or 6 numeric columns and one row for each location. See file.format. One of file and coordmatrix needs to be specified (if coord
coordmatrix
something that can be coerced into a matrix with 2, 4 or 6 columns. Matrix of coordinates, one row for each location. See file.format. One of file and coordmatrix needs to be specified.
cut
numeric. Only active if neighbors==TRUE; see neighbors.
file.format
one of "degminsec", "decimal2" or "decimal4". The format of the required file or coordmatrix consists of the following columns: [object Object],[object Object],[object Object]
output.dist
logical. If TRUE, the resulting distance matrix is given out as a dist object.
radius
numeric. Radius of the earth in km used in computation (the default is the equatorial radius but this is not the uniquely possible choice).
fp
flattening of the earth; the default is from WGS-84.
neighbors
logical. If TRUE, a neighborhood list is also computed, listing for every location all locations with distance <=cut< code=""> as neighbors.

Value

  • If neighbors==TRUE, a list with components
  • distmatrixdistance matrix between locations. See output.dist above. This is in km by default; the measurement unit is determined by the value used for radius.
  • nblistlist with a vector for every location containing the numbers of its neighbors, see neighbors.
  • If neighbors==FALSE, only the distance matrix.

References

German Wikipedia from 29 August 2010: http://de.wikipedia.org/wiki/Orthodrome

See Also

geo2neighbor

Examples

Run this code
data(veronica)
  coord2dist(coordmatrix=veronica.coord[1:20,], cut=20, file.format="decimal2",neighbors=TRUE)

Run the code above in your browser using DataLab