OSM 路网提取
OSM 路网提取
-
highway=*tag -
Osmosis工具 -
Python 库:
OSMnx -
Python 库:
OSM2GMNS
1. OSM 中道路元素信息
通过 highway=* 指示
2. Osmosis 工具 过滤标签
2.1 Osmosis 工具简介
Osmosis: Osmosis OSM website; Detailed Usage
2.1 实例
实例 1: 提取所有 highway=* 的标签
osmosis ^
--read-xml city.osm ^
--tag-filter ^
accept-ways highway=* ^
--used-node ^
--write-xml highways.osm
--tag-filter提取标签或(--tf)- 参数:
accept-ways和reject-ways
- 参数:
实例 2: 提取公共道路。来源:OSMnx 库 drive 过滤条件 site
osmosis ^
--read-xml city.osm ^
--tf accept-ways highway=* ^
--tf reject-ways ^
area=yes ^
access=private ^
highway=abandoned,bridleway,bus_guideway,construction,corridor,cycleway,elevator,escalator,footway,path,pedestrian,planned,platform,proposed,raceway,service,steps,track ^
motor_vehicle=no ^
motorcar=no ^
service=alley,driveway,emergency_access,parking,parking_aisle,private ^
--used-node ^
--write-xml city-network.osm
注意: ^ 在 windows cmd 中表示连接,在 linux 系统中,用 \
3 Python 库:OSMnx
3.1 简介
-
将 OSM 路网优化为
NetworkX中的Graph -
建议
-
先使用
osmosis工具从原始 OSM 文件中提取路网标签,即:highway=* -
注意:
OSMnx库遇到缺失点会报错
-
-
实例代码
import osmnx as ox
osm_file = r'network.osm'
save_path = r'/network'
# extract graph (networkx.Graph object) from osm file
net = ox.graph.graph_from_xml(osm_file,
network_type="drive",
retain_all=False)
# save to shapefile
ox.io.save_graph_shapefile(net, save_path)
3.3 预设路网过滤条件
提取路网的 6 种设置(site)
'drive'
["highway"]
["area"!~"yes"]
["access"!~"private"]
["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|elevator|escalator|footway|path|pedestrian|planned|platform|proposed|raceway|service|steps|track"]
["motor_vehicle"!~"no"]
["motorcar"!~"no"]
["service"!~"alley|driveway|emergency_access|parking|parking_aisle|private"]
'drive_service'
["highway"]
["area"!~"yes"]
["access"!~"private"]
["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|elevator|escalator|footway|path|pedestrian|planned|platform|proposed|raceway|steps|track"]
["motor_vehicle"!~"no"]
["motorcar"!~"no"]
["service"!~"emergency_access|parking|parking_aisle|private"]'
'walk'
["highway"]
["area"!~"yes"]
["access"!~"private"]["highway"!~"abandoned|bus_guideway|construction|cycleway|motor|planned|platform|proposed|raceway"]["foot"!~"no"]
["service"!~"private"]',
'bike'
["highway"]
["area"!~"yes"]
["access"!~"private"]
["highway"!~"abandoned|bus_guideway|construction|corridor|elevator|escalator|footway|motor|planned|platform|proposed|raceway|steps"]
["bicycle"!~"no"]
["service"!~"private"]
'all'
["highway"]
["area"!~"yes"]
["access"!~"private"]
["highway"!~"abandoned|construction|planned|platform|proposed|raceway"]
["service"!~"private"]
'all_private'
["highway"]
["area"!~"yes"]
["highway"!~"abandoned|construction|planned|platform|proposed|raceway"]
4 OSM2GMNS
OSM2GMNS: github

浙公网安备 33010602011771号