Description Usage Arguments Value Note Author(s) References See Also Examples
The function returns a vector of distances between a matrix of 2D points, first column longitude, second column latitude, and a single 2D point, using Euclidean or Great Circle distance (WGS84 ellipsoid) methods.
1 2 |
pts |
A matrix of 2D points, first column x/longitude, second column y/latitude, or a SpatialPoints or SpatialPointsDataFrame object |
pt |
A single 2D point, first value x/longitude, second value y/latitude, or a SpatialPoints or SpatialPointsDataFrame object with one point only |
x |
A matrix of n-D points with row denoting points, first column x/longitude, second column y/latitude, or a Spatial object that has a coordinates method |
y |
A matrix of n-D points with row denoting points, first column x/longitude, second column y/latitude, or a Spatial object that has a coordinates method |
longlat |
if FALSE, Euclidean distance, if TRUE Great Circle distance |
spDistsN1
returns a numeric vector of distances in the metric of the points if longlat=FALSE, or in kilometers if longlat=TRUE.
spDists
returns a full matrix of distances in the metric of the points if longlat=FALSE, or in kilometers if longlat=TRUE; it uses spDistsN1
in case points are two-dimensional. In case of spDists(x,x)
, it will compute
all n x n distances, not the sufficient n x (n-1).
The function can also be used to find a local kilometer equivalent to a plot scaled in decimal degrees in order to draw a scale bar.
Roger Bivand, Edzer Pebesma
http://www.abecedarical.com/javascript/script_greatcircle.html
1 2 3 4 5 6 7 8 9 10 11 12 | ll <- matrix(c(5, 6, 60, 60), ncol=2)
km <- spDistsN1(ll, ll[1,], longlat=TRUE)
zapsmall(km)
utm32 <- matrix(c(276.9799, 332.7052, 6658.1572, 6655.2055), ncol=2)
spDistsN1(utm32, utm32[1,])
dg <- spDistsN1(ll, ll[1,])
dg
dg[2]/km[2]
data(meuse)
coordinates(meuse) <- c("x", "y")
res <- spDistsN1(meuse, meuse[1,])
summary(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.