Computes pairwise distances between geometries. For geographic (longlat)
coordinate systems, uses great circle distances in meters via sf::st_distance().
For projected coordinate systems, uses fast Euclidean distance in the CRS units
(typically meters).
Usage
distance_matrix(
x,
y = NULL,
type = c("euclidean", "manhattan"),
use_centroids = NULL
)Arguments
- x
An sf object (demand points for facility location, or areas for regionalization).
- y
An sf object (facility locations). If NULL, computes distances within x.
- type
Distance type: "euclidean" (default) or "manhattan". Note that for geographic CRS, only "euclidean" (great circle) distance is available.
- use_centroids
Logical. If TRUE (default for polygons), use polygon centroids.
