如何从 osmnx 以 .svg 格式正确下载地图?

How do I correctly download a map from osmnx as .svg?

我是 Python 的新手。刚刚使用 OSMnx 并想在 Illustrator 中以 svg 格式打开地图。这已发布在 GitHub 文档中:

# 你也可以 plot/save 图形作为 SVG 稍后在 Illustrator 中使用 图,ax = ox.plot_graph(G_projected, save=True, file_format='svg')

我在 JupyterLab 中试过了,它下载到我的文件中,但是当我打开它时,它只是文本。如何正确下载并以 SVG 格式打开? - 谢谢!

fig, ax = ox.plot_graph(G, filepath='image.svg', save=True, show=False, close=True)

运行 行代码。它保存一个名为 image.svg 的 SVG 文件。在您选择的 SVG 程序(Adobe Illustrator 等)中打开该文件。

[编辑:更新了最新 OSMnx 版本的代码片段]

而不是

filename='image', file_format='svg'

使用:

filepath='image.svg'