Created
October 15, 2023 12:02
-
-
Save JosiahParry/ad4eabf9b38e6c3c2402ca736a06527d to your computer and use it in GitHub Desktop.
Spatially implicit edges based on a minimum spanning tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sfdep) | |
library(sfnetworks) | |
nb <- st_contiguity(guerry) | |
wt <- st_weights(nb) | |
listw <- recreate_listw(nb, wt) | |
mstree <- spdep::mstree(listw, 1) | |
edges <- data.frame( | |
from = as.integer(mstree[,1]), | |
to = as.integer(mstree[,2]), | |
weight = mstree[,3] | |
) | |
sfnetwork( | |
sf::st_centroid(guerry), | |
edges | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To make the edges explicit: