Computes a distance matrix from a given set of polygons
(SpatialPolygonsDataFrame)
Usage
DistanceMatrix(poly, id, unit = 1000, longlat = TRUE, fun = distHaversine)
Arguments
poly
A SpatialPolygonsDataFrame
id
The id used to as area ids
unit
meters per unit in the distance matrix. The default unit = 1000 outputs a distance matrix in kilometres, in most of the cases.
With different type of projections unit can be used to properly calibrate the metric unit.
longlat
if TRUE indicates that the distance is calculated using longitude and latitude coordinates and a spherical distance functions (to be used with CRSGPS).
If FALSE, the distance is computed as the euclidean distance on the flat projection (to be used with CRSCH1903). Default is TRUE.
fun
A function to compute distances with longitude and latitude coordinates (e.g., distCosine, distHaversine, distVincenty*) to be passed to distm. It works only if longlat=TRUE
Value
A square distance matrix
Author(s)
Mathieu Cossuta, Davide Morselli, Till Junge, Sandra Penic, Guy Elcheroth
Examples
## load the CRS projection definition and a shape file
data(CH1903)
## Not run:
yu.reg <- ReadPoly("path/to/my/shapefile.shp", proj = CH1903)
data(yu.reg)
names(yu.reg) <- "area.name"
d.geo <- DistanceMatrix(yu.reg, "area.name", longlat = FALSE)
## End(Not run)