You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取SUMO路网文件osm.net.xml中车道(lane)的地理坐标

方法1:新增netconvert参数直接导出带车道坐标的plain文件

原有命令仅输出edge形状是因为plain格式输出默认不包含车道级几何信息,只需新增--plain-output.lane-shapes参数即可获取车道的地理坐标,完整命令如下:

netconvert --sumo-net-file osm.net.xml --plain-output-prefix plain --proj.plain-geo --plain-output.lane-shapes true

执行后生成的plain.lan.xml文件中,每个<lane>标签会携带shape属性,属性值为空格分隔的经纬度坐标对,对应车道的地理坐标形状。


方法2:用sumolib脚本自定义提取车道坐标

如果需要更灵活的后续处理逻辑,可以直接使用SUMO官方Python工具库sumolib读取路网文件,自主转换输出车道地理坐标,示例代码如下:

import sumolib

# 读取路网文件,自动加载内置投影配置
net = sumolib.net.readNet('osm.net.xml', withGeo=True)

# 遍历所有车道提取地理坐标
for edge in net.getEdges():
    for lane in edge.getLanes():
        # 转换路网本地XY坐标为WGS84经纬度
        lane_geo_shape = [net.convertXY2LonLat(x, y) for x, y in lane.getShape()]
        # 可自定义输出逻辑,如写入CSV、数据库等
        print(f"车道ID:{lane.getID()},地理坐标:{lane_geo_shape}")

运行前需先安装依赖:执行pip install sumolib即可


内容的提问来源于stack exchange,提问作者Asif Mehmood

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 10:48:02