简体   繁体   中英

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. 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

In order to save the file I used the following line of code as suggested in the osmnx documentation :

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?

I am using 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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