Hi Giuliana, Thank you very much, this is exactly what I needed.
I could work out my problem :). Have a good day, Antoine Le 09/07/2020 à 19:17, [email protected] a écrit : > 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: [email protected] [mailto:[email protected]] On > Behalf Of [email protected] > Sent: Donnerstag, 9. Juli 2020 17:33 > To: [email protected] > 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 > [email protected] > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/sumo-user > _______________________________________________ > sumo-user mailing list > [email protected] > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/sumo-user > _______________________________________________ sumo-user mailing list [email protected] To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
