distance_matrix | R Documentation |
Convert Long-Format Distance Tibble to Matrix
distance_matrix(distances, distance_col = "fds")
distances |
tibble with columns flow_ID_a, flow_ID_b, and distance |
distance_col |
column name for distance (default "fds") |
distance matrix (tibble with rownames). The matrix has flow_ID_a as rownames and flow_ID_b as column names.
This function converts the output of flow_distance()
into a format suitable for the dbscan clustering algorithm.
flows <- sf::st_transform(flows_leeds, 3857)
flows <- head(flows, 100) # for testing
# Add flow lengths and coordinates
flows <- add_flow_length(flows)
flows <- add_xyuv(flows)
# Calculate distances
distances <- flow_distance(flows, alpha = 1.5, beta = 0.5)
dmat <- distance_matrix(distances)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.