2

我正在尝试使用 visNetwork 绘制地理 igraph 网络。igraph 代码如下,我找到了这个 visNetwork 解决方案,但我在正确调整代码时遇到问题https://github.com/DataKnowledge/visNetwork/blob/master/R/visIgraphLayout.R

library(raster)
library(igraph)
greece <- getData('GADM', country='GRC', level=1)
df<-data.frame("from" = c("Athens", "Iraklio", "Thessaloniki", "Patra"), "to"= c("Thessaloniki", "Thessaloniki", "Athens", "Iraklio"))
meta <- data.frame("name"=c("Athens", "Iraklio", "Thessaloniki", "Patra"), 
           "lon"=c(23.72800,25.13356,22.94090,21.73507),  
           "lat"=c(37.98415,35.33349,40.63229,38.24628))
g <- graph.data.frame(df, directed=T, vertices=meta)
lo <- as.matrix(meta[,2:3])
plot(greece)
plot(g, layout=lo, add = TRUE, rescale = FALSE)

编辑 更新

我有一个 R-igraph 网络,这是使用 visNetwork 库可视化的。我有一个空间数据框,这是使用 Leaflet 可视化的。如何在地图上可视化网络但保留 visNetwork 功能?在此处查看示例

4

0 回答 0