我有一组给定节点的纬度和经度值。我将这些纬度、经度投影到 x,y 并将它们输入 .dot 代码并使用 graphviz 2.29 生成图形。 命令是:
neato -Tpng -o sample.png sourcegv.dot
输出图为: http://www.freeimagehosting.net/brpnt
生成此图的源代码是:
digraph {
rankdir=LR;
subgraph cluster1{
label="cluster 1"
node[style=filled,color=cornflowerblue, fontcolor=white]
edge[arrowhead=vee, color=maroon]
n0[label="192.168.8.9" pos = "69.0,15.5!"];
n1[label="192.168.8.8" pos = "70.25,12.75!"];
n2[label="192.168.8.6" pos = "78.0,9.5!"];
n0 -> n1 ;
n1 -> n2 ;
n0 -> n2 ;
n2 -> n1 ;
n2 -> n0 ;
n1 -> n0 ;
};
subgraph cluster2{
label="cluster 2"
node[style=filled,color=cornflowerblue, fontcolor=white]
edge[arrowhead=vee, color=maroon]
m0[label="192.168.8.9" pos = "70.5,18.25!"];
m1[label="192.168.8.8" pos = "75.25,17.75!"];
m2[label="192.168.8.6" pos = "70.25,16.5!"];
m0 -> m1;
m1 -> m2 ;
m0 -> m2 ;
m2 -> m1 ;
m2 -> m0 ;
m1 -> m0 ;
};
}
我正在寻找一些方法,以便我可以在真实 map (如谷歌地球或谷歌地图)中绘制图形,以便节点可以固定到纬度和经度给定的位置.
谢谢。
最佳答案
不幸的是,Graphviz 并不是适合这项工作的工具。它适用于图表,而不是 map 。但是,有一些非常好的选择:
Matplotlib 的 Basemap :它是用Python编写的,但你只需要了解一点点就可以使用它。 Matplotlib 有大量的 examples ,但找到好的教程很容易。这是 good tutorial on the Basemap package也是。
Google Maps API :您只需将标签、纬度和经度传递给 API 即可绘制标记。您可以生成static images或交互式 map 。
为了完整起见,您可能需要查看 JavaScript 库,例如 Cartographer.js或Polymaps
遗憾的是,这些都不像 dot
语言那么简单,但 Matplotlib 非常接近。
关于dictionary - 将 graphviz 绘制为 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12835916/