Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Convert trips to list of nodes
  • From: <Maria.Armellini@xxxxxx>
  • Date: Thu, 9 Jul 2020 17:17:52 +0000
  • Accept-language: de-DE, en-US
  • Delivered-to: sumo-user@xxxxxxxxxxx
  • Ironport-phdr: 9a23:TLKrkRwnGoHj9VjXCy+O+j09IxM/srCxBDY+r6Qd0uoeKfad9pjvdHbS+e9qxAeQG9mCtbQd2qGH6+igATVGvc/c9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfQV6Kf7oFYHMks+5y/69+4HJYwVPmTGxfa5+IA+5oAnMt8Qam5ZuJ6I+xhbNvndDZuBayX91KV6JkBvw+8e98IR//yhMvv4q6tJNX7j9c6kkV7JTES4oM3oy5M3ltBnDSRWA634BWWgIkRRGHhbI4gjiUpj+riX1uOx92DKHPcLtVrA7RS6i76ZwRxD2jioMKiM0/3vWisx0i6JbvQ6hqhliyIPafI2ZKPxzdb7bcNgHR2ROQ9xRWjRBDI2icoUPE+QPM+VWr4b/plsBsRSwCga3CePz0z9IhGP60bEm3+g/FwzNwQwuH8gJsHTRtNj4M6AcXvqvzKnJ1zrPde9b2S346IfWdhAhpfCMXbRxccfK1EYvExnFgk+NpoP7Jj6Y0PkGvGeH4eR6T+2vl3InpB9rojip3soihIbEi4AWx13A+it0wIk7KNO8RUN5YtOqH59duiWYOoV2X84uXWFmtSU6x7AHpZK3YigExYg7yxPca/KLb4aF7xT+X+ifJjd4gWhqeLO5hxuq7Eegzvf8WtOp31lUtiZFicTMtnUK1xzX68iIUeFx/kG/1jaTzwzT7+FFIUYqmqrHMZIhxKA/loYLvUvdAiD2nET2jLeNdko64OSo7P7nYrrgq5SBNIF0khnzPrkylsClHOg1MQcDU3KG9emy17Dv51P1TKtSgvErkKTVrorWKdoGqqKjHgNY0Icu5wyiAzqgzd8Wh2MILEhfdxKCl4XpPlbOL+3mAvqnmFSslStrx+jBPr38HpXBNnjDn6nlfbZ680NSxgw9w95Q6ZxUCr8PJ/H9VEjrutDGEBM3PA27zvj9BNV80IMeRXiPDbWDPKzPtV+I/PgjLPSSa4MNuTb9LeYq5+L2gHMkhVMRZ7Sl0JgYZXyiA/hrLUaUbWDyjtsfCWsKuxAxTO3uiF2MSz5TYHOyUro76D4hEoKmDJ3MSpqxjbyb2Se0AJlWZmRHClCKEHflbJiLW/MWaC6IP8BujCQIVaK9RI85yRGuqAj6xqJ8LurJ/y0Ysovv1MVu5+LNjxE/7iJ7ANiZ02GMV2F0hX0HSyUx3KBlrkwugmqFyrVy1vxECcRItbQOTRglc5PXy+1iEN20XRjOOdKASVKjS9PhBTAqUtM3zdhJeFt4HJC/lR3ZjBesGKIfq7GbGMk07r7ExCq2YNli1DDL360gl0IrBMxVOiqjj6978gHVQIrIiFmYkaitMr8B2SmI6XyO1zmyuxQMSxN1VuDYRn0FTkbdqdXh/U6ESKWhX+cJKAxEnJqnI7FLY5vAl1BLQPPiPtX2b2ar3Wu9U0XbjoiQZZbnLj1OlB7WD1IJxlge
  • Ironport-sdr: ErQytoPWYbacoN7ZUslm0AU2J1WaupFoIabrAx6hNUqNWULZeSGiYJxmyNyoue2zmLlJW2ldAc mqkTY8FvQ16Q==
  • List-archive: <https://www.eclipse.org/mailman/private/sumo-user>
  • List-help: <mailto:sumo-user-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHWVgZPiSl2dqppLEWUiSOCv5apB6j/eQwg
  • Thread-topic: [sumo-user] Convert trips to list of nodes

Hi Antoine,

The "edges" attribute in the route file shows the consecutive edges id of the route.
<route edges="35049297 -173282740 150031197#8" /> This route is composed of three edges with ids 35049297, -173282740 and 150031197#8.

Regarding your first question, you can use sumolib in python to parse the network and the route file. See https://sumo.dlr.de/docs/Tools/Sumolib.html for some examples.  
You could for example read all edges ids in each route and use the "from node" attribute to get the node id. For a list of all node ids in the network, you can use getNodes(). This can be done with the following Python code:

import os, sys
if 'SUMO_HOME' in os.environ:
    tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
    sys.path.append(tools)
else:   
    sys.exit("please declare environment variable 'SUMO_HOME'")

# import the library
import sumolib

# parse the net
net = sumolib.net.readNet('myNet.net.xml')

# parse all nodes in the net
node_ids = [node.getID() for node in net.getNodes()]

# parse all edges in the route file
for route in sumolib.output.parse_fast('myRoutes.rou.xml', 'route', ['edges']):
    route_edges = route.edges.split()
    
   # get node ids instead of edge ids
    route_nodes = [net.getEdge(edge).getFromNode().getID() for edge in route_edges]
    # do something with the vector of node ids


Regards,
Giuliana

-----Original Message-----
From: sumo-user-bounces@xxxxxxxxxxx [mailto:sumo-user-bounces@xxxxxxxxxxx] On Behalf Of eclipse.eprok@xxxxxxxxxxxxxxx
Sent: Donnerstag, 9. Juli 2020 17:33
To: sumo-user@xxxxxxxxxxx
Subject: [sumo-user] Convert trips to list of nodes

Hello,

I am working on graph algorithms. I use python and networkx.
I would like to work with the data from the TAPAS Cologne scenario
(https://sumo.dlr.de/docs/Data/Scenarios/TAPASCologne.html).

I would like to have the graph corresponding to the road network in the
format: "node1 node2", along with a list of nodes for each trajectory.

How could I do that?

I successfully converted the road network to a format that networkx
understands but the tool that I used renamed the nodes, so I can't use it.

As for the trajectories, I have a .rou.xml file with <route
edges="35049297 -173282740 150031197#8" />. What is between quotes? Is
it the list of nodes of the trajectory?

Thanks for your help,
Antoine

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user


Back to the top