【问题标题】:Can anyone tell me how to get the geo-coordinates of lanes also?谁能告诉我如何获得车道的地理坐标?
【发布时间】:2021-11-27 06:56:30
【问题描述】:

我有一个文件osm.net.xml,取自真实地图。该文件包括边缘和车道的形状(X/Y 坐标)。我运行以下命令来转换/创建文件以包含地理坐标:

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

输入文件如下(包括edgeslanes的x/y坐标):

我得到的输出文件为:

我没有看到任何包含车道地理坐标的输出文件。在plain.edg.xml 中,只有边缘的形状信息,而没有车道的形状信息:

谁能告诉我如何获取lanes 的地理坐标???

【问题讨论】:

    标签: xml openstreetmap sumo


    【解决方案1】:

    目前无法执行此操作。您只能尝试使用 python 脚本解析网络并自己进行地理转换,请参见此处的示例:https://sumo.dlr.de/docs/Tools/Sumolib.html#import_a_network_and_retrieve_nodes_and_edges 它可能会归结为:

    import sumolib
    net = sumolib.net.readNet('myNet.net.xml')
    laneShape = net.getLane('myLaneID').getShape()
    for x, y in laneShape:
        lon, lat = net.convertXY2LonLat(x,y)
    

    【讨论】:

    • 谢谢@Micheal。这很有帮助。这很棒。这种转换是否需要很多时间。我在问在正在运行的 python 应用程序服务器中将 X/Y 转换为 lon/lat 是否是一种好的/有效的方法。还是在配置应用程序之前一次性将 x/y 转换为 lon/lat 更好?
    • 我不确定,但它不应该太慢,我会试一试。您仍然可以稍后进行优化。
    【解决方案2】:

    我做了这样的事情来读取整个XML 文件。将每个 x,y 对值转换为经度、纬度,如下所示:

    # Read the XML file 
    tree = et.parse(PATH_TO_XML_FILE) 
    file = tree.getroot() 
    
    geoCoordinatesString = "" 
    
    # Iterate edge nodes in the file 
    for edge in file.iter('edge'): 
    
        # Iterate lanes of the current edge-node 
        for lane in edge.iter('lane'): 
            laneID = lane.get("id") 
            laneShape = lane.get("shape") 
            laneCoordinates = laneShape.split() 
            geoCoordinatesString = "" 
    
            # Iterate each coordinate in the shape of lane 
            for coordinate in laneCoordinates: 
                geoCoordinates = np.array(coordinate.split(",")) 
                geoCoordinates = geoCoordinates.astype(float) 
                geoCoordinateLon, geoCoordinateLat = net.convertXY2LonLat(geoCoordinates[0],geoCoordinates[1]) 
                geoCoordinatesString = "{:}{:},{:} ".format( 
                    geoCoordinatesString, str(geoCoordinateLon), str(geoCoordinateLat) 
                ) 
    
            # Display each lane's shape geo-coordinates 
            geoCoordinatesString = geoCoordinatesString.strip() 
            print ("- {:}".format(geoCoordinatesString)) 
    

    此输出允许我存储与车道 ID 关联的车道信息。

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多