简体   繁体   English

如何使用python从OpenStreetMap网站导出的.osm文件的相同结构中,使用python将OSM文件保存为XML?

[英]How to save OSM file in XML using python in the same structure of the exported .osm file from OpenStreetMap website?

I am using python osmnx to deal with OpenStreetMap and I am trying to save a networkx map in an .xml file with the same structure of the exported one from the openstreetmap.org. 我正在使用python osmnx处理OpenStreetMap,并且尝试将networkx映射保存在.xml文件中,其格式与从openstreetmap.org导出的映射相同。 Is it possible to save the map in same XML structure as downloaded from website? 是否可以将地图保存为与从网站下载的XML相同的XML结构?

I am using osmnx for path planning and I am trying to save the map that includes the path in .xml format for further operations using ox.save_graphml() , which saves the map but in a different structure than the exported map for the same area from the OSM website. 我正在使用osmnx进行路径规划,并且正在尝试使用ox.save_graphml()保存包含.xml格式的路径的地图,以便进行进一步操作,这会保存该地图,但与用于同一区域的导出地图的结构不同从OSM网站。

ox.save_graphml(subgraph2 , filename='/home/ahmad/catkin_ws/src/osmgraph.xml')

I expect the XML file to have the same structure as the one from the exported .osm file from OpenStreetMap. 我希望XML文件的结构与从OpenStreetMap导出的.osm文件的结构相同。 But the output XML has different structure. 但是输出XML具有不同的结构。

Per the OSMnx documentation , save_graphml saves your graph to disk as a GraphML file. 根据OSMnx文档save_graphml将图形作为GraphML文件保存到磁盘。 The GraphML file format is unrelated to the OSM XML file format . GraphML文件格式OSM XML文件格式无关。 OSMnx can save your graph to disk as a shapefile or GraphML. OSMnx可以将图形作为shapefile或GraphML保存到磁盘。 It does not support saving to disk as an OSM XML file out of the box. 它不支持开箱即用OSM XML文件形式保存到磁盘。

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

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