pythonsumoproj

Recreate sumo projection


After converting osm file to sumo network I got this info

<location netOffset="-395885.58,-6185860.67" convBoundary="0.00,0.00,3442.30,2845.95" origBoundary="37.338524,55.806366,37.393811,55.835368" projParameter="+proj=utm +zone=37 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"/>

I would like to convert some (lat, long) coordinates to sumo projection coordinates. How can I do this? I know that some similar functions are provided by pyproj library, but don't understand, how to use it here


Solution

  • The easiest way is described here: https://sumo.dlr.de/docs/Tools/Sumolib.html#coordinate_transformations

    import sumolib
    net = sumolib.net.readNet('myNet.net.xml')
    
    x, y = net.convertLonLat2XY(lon, lat)
    

    You can find sumolib in SUMO's tools folder or install it using pip.