Created
November 11, 2021 18:28
-
-
Save idshklein/1556f9a7b49a21d65692e01bbe62e99e to your computer and use it in GitHub Desktop.
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(tidyverse) | |
library(sf) | |
library(sfnetworks) | |
library(cluster) | |
library(crsuggest) | |
library(tidygraph) | |
library(ggspatial) | |
# library(gganimate) | |
crsuggest::suggest_crs(roxel) | |
net <- roxel %>% | |
st_transform(5683) %>% | |
as_sfnetwork() %>% | |
filter(group_components()==1) | |
mat <- net %>% | |
st_network_cost() | |
dianamat <- diana(mat) | |
states <- map(1:20,function(x){ | |
clus <- dianamat %>% cutree(x) | |
net %>% | |
mutate(clus = clus, nclus = x,rn = row_number()) %>% | |
st_as_sf() | |
}) %>% | |
bind_rows() | |
states %>% | |
filter(nclus < 11) %>% | |
ggplot(aes(group = rn,color = factor(clus))) + | |
annotation_map_tile(zoom = 14) + | |
geom_sf() + | |
facet_wrap(~nclus) | |
# transition_states(nclus) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment