简体   繁体   English

如何在python中使用osmnx将图形保存为.osm格式?

[英]How to save graph to .osm format with osmnx in python?

I am using the python library osmnx to obtain a graph from an airport.我正在使用 python 库 osmnx 从机场获取图表。 I can easily do it by using the following line of code:我可以使用以下代码行轻松完成:

import osmnx as ox
G = ox.graph_from_place('wien flughafen austria', infrastructure='way["aeroway"]',simplify=False, custom_filter = ('["aeroway"~"taxiway|taxilane|parking_position"]'))

Now my goal is to save this file in the osm format so I can then opend it with another software called Java OpenStreatMap Editor现在我的目标是以 osm 格式保存这个文件,这样我就可以用另一个名为Java OpenStreatMap Editor 的软件打开它

In order to save the file I used the following line of code as suggested in the osmnx documentation :为了保存文件,我按照osmnx 文档中的建议使用了以下代码行:

ox.save_load.save_as_osm(G, 'test.osm')

However this doesn't seem to work.但是,这似乎不起作用。 Would you be able to suggest me the correct way to save the graoh to the osm format?您能否建议我将 graoh 保存为 osm 格式的正确方法?

I am using osmnx=0.11.1.我正在使用 osmnx=0.11.1。 The following should work.以下应该工作。

ox.save_load.save_graph_osm(G, filename='test.osm')

regarding the building footprints that you asked in the comments above, you just do关于您在上述评论中询问的建筑足迹,您只需

GeoDataFrame.to_file("GeoDataFrame_name.shp")

and it is saved as a shapefile in your working directory并将其保存为工作目录中的 shapefile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM