Computes geographical distances from geographical coordinates
coord2dist(file=NULL, coordmatrix=NULL, cut=NULL,
file.format="degminsec",
output.dist=FALSE, radius=6378.137,
fp=1/298.257223563, neighbors=FALSE)If neighbors==TRUE, a
list with components
distance matrix between locations. See
output.dist above. This is in km by default; the measurement
unit is determined by the value used for radius.
list with a vector for every location containing the
numbers of its neighbors, see neighbors.
If neighbors==FALSE, only the distance matrix.
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 coordmatrix is not specified,
coordinates are read from file).
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.
numeric. Only active if neighbors==TRUE; see
neighbors.
one of "degminsec", "decimal2" or
"decimal4". The format of the required file or
coordmatrix consists of the following columns:
6 columns; the first three give degrees, minutes and seconds for latitude, columns 4-6 the same for longitude. Values in column 1 and 4 can be positive or negative (negative means "South", "West", respectively). Values in the other columns should be non-negative.
2 columns; the first one gives latitude, the second one longitude in proper decimal notation. Values can be positive or negative (negative means "South", "West", respectively).
4 columns; the first two give latitude, no. 3
and 4 give longitude. Values in column 1 and 3 can be positive
or negative (negative means "South", "West",
respectively). The give integer degrees. Values in the other
columns should be non-negative. They give percentages
(<=100).
logical. If TRUE, the resulting distance
matrix is given out as a dist object.
numeric. Radius of the earth in km used in computation (the default is the equatorial radius but this is not the uniquely possible choice).
flattening of the earth; the default is from WGS-84.
logical. If TRUE, a neighborhood list is also
computed, listing for every location all locations with distance
<=cut as neighbors.
Christian Hennig christian.hennig@unibo.it https://www.unibo.it/sitoweb/christian.hennig/en
German Wikipedia from 29 August 2010: https://de.wikipedia.org/wiki/Orthodrome
geo2neighbor
options(digits=4)
data(veronica)
coord2dist(coordmatrix=veronica.coord[1:20,], cut=20, file.format="decimal2",neighbors=TRUE)
Run the code above in your browser using DataLab