python的osmnx包

xiaoxiao2021-02-28  90

openstreetmap是免费地理数据下载的网站,而osmnx是一个用于从openstreetmap下载边界并分析和可视化街道网络python包是Geoff Boeing大神所编写,安装OSMnx时建议在anaconda下安装[人生苦短,快用anaconda],如果不想装anaconda也可以使用Miniconda轻量级;osmnx依赖geopandas库geopandas库又依赖gdal、fiona、pyproj、pandas等等

1.获取深圳行政区域和深圳道路网络集

import osmnx as ox city=ox.gdf_from_place("南山区,深圳市,中国") print city ox.plot_shape(ox.project_gdf(city))

treet=ox.graph_from_place("shenzhen,china",which_result=2) ox.plot_graph(treet)

通过某一位置查询,例如腾讯总部大厦周围的1公里驾驶道路网

location =ox.graph_from_point((22.5436253,113.9299285),distance=1000,network_type='drive') ox.plot_graph(location)

2.下载道路网络到本地磁盘并保存shp格式

treet=ox.graph_from_place("shenzhen,china",which_result=2) ox.plot_graph(treet) ox.save_graph_shapefile(treet,filename='sz')

当然也可以做简单的拓扑和分析,大家可以根据自已需求尽情玩一玩。

参考文献

http://geoffboeing.com/2016/11/osmnx-python-street-networks/

https://osmnx.readthedocs.io/en/latest/osmnx.html#module-osmnx.save_load

转载请注明原文地址: https://www.6miu.com/read-84690.html

最新回复(0)