利用QGIS批量下载OSM数据中的地铁线路矢量数据

要在Python中批量下载OSM数据中的地铁线路矢量数据并获取地铁站点数据,使用OSMnx和geopandas库。以下是一些代码,


import osmnx as ox
import geopandas as gpd

# 定义一个地点
location_point = (51.5072, -0.1276)

# 下载地图并绘制地图
graph = ox.graph_from_point(location_point, dist=1000, network_type='all')
ox.plot_graph(graph)

# 获取地铁站点数据
stations = ox.pois_from_place('London', amenities=['station'], tags={'railway': 'station', 'station': 'subway'})

# 获取地铁线路数据
subway = ox.graph_from_place('London', network_type='all', custom_filter='["railway"~"subway"]')

# 保存地铁线路和站点数据为shapefile格式
ox.save_graph_shapefile(subway, filename='london_subway', folder='subway_data')
stations.to_file('subway_data/london_subway_stations.shp')
 

这将下载伦敦地区的地铁线路矢量数据,并将其保存为shapefile格式。您可以使用类似的代码来下载其他城市的数据。

你可能感兴趣的:(python)