distm_km {remotePARTS} | R Documentation |
Calculate a distance matrix from coordinates
Description
Calculate the distances among points from a single coordinate matrix or
Usage
distm_km(coords, coords2 = NULL)
distm_scaled(coords, coords2 = NULL, distm_FUN = "distm_km")
Arguments
coords |
a coordinate matrix with 2 columns and rows corresponding to each location. |
coords2 |
an optional coordinate matrix |
distm_FUN |
function used to calculate the distance matrix. This function dictates the units of "max.dist" |
Details
distm_km
is simply a wrapper for geosphere::distm()
Value
distm_km
returns a distance matrix in km
A distance matrix is returned.
If coords2 = NULL
, then distances among points in coords
are
calculated. Otherwise, distances are calculated between points in coords
and coords2
distm_km
returns a distance matrix in km and distm_scaled
returns
relative distances (between 0 and 1). The resulting matrix has the attribute
"max.dist" which stores the maximum distance of the map. "max.dist" is in
km for distm_km
and in the units of distm_FUN
for distm_scaled
.
See Also
?geosphere::distm()
Examples
map.width = 3 # square map width
coords = expand.grid(x = 1:map.width, y = 1:map.width) # coordinate matrix
distm_scaled(coords) # calculate relative distance matrix