Hi, the way to do it is: net = sumolib.net.readNet('myNet.net.xml') for edge in net.getEdges(): if edge.getID() == myedgeid: length = edge.getLength()
You can parse the net directly but then you do not always have a length attribute (only if there is a user defined length for the edge). Best regards, Michael Am 05.07.2018 um 17:33 schrieb Stefano Niero via sumo-user: > Dear Sumo Community, > I would like to ask how it is possible to retrieve the length of an edge > through Python. Based on what I found here: > http://sumo.dlr.de/wiki/Tools/Sumolib > at the paragraph: "compute the average and median edge length in a plain xml > edge file", I wrote the following code: > for edge in sumolib.output.parse('myNet.net.xml', ['edge']): > if edge.id == myedgeid: > length = edge.length > But this solution is not working as the script is able to find effectively > edge.id but that, through debugging I found that edge.length is an empty > veriable. I looked a little through the internet but I got a little bit > confused about the answer I found. How can I retrieve the length of a > particular edge? > > Thank you very much in advance > Stefano Niero > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > sumo-user mailing list > sumo-u...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sumo-user > _______________________________________________ > sumo-user mailing list > sumo-user@eclipse.org > To change your delivery options, retrieve your password, or unsubscribe from > this list, visit > https://dev.eclipse.org/mailman/listinfo/sumo-user >
signature.asc
Description: OpenPGP digital signature
_______________________________________________ sumo-user mailing list sumo-user@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/sumo-user