def convertNodesCoordinates(graph, sourceEPSG, targetEPSG):
sourceProjection = osr.SpatialReference()
sourceProjection.ImportFromEPSG(sourceEPSG)
destinationProjection = osr.SpatialReference()
destinationProjection.ImportFromEPSG(targetEPSG)
coordTrans = osr.CoordinateTransformation(sourceProjection, destinationProjection)
for node in graph.nodes():
x, y = graph.node[node]['longitude'], graph.node[node]['latitude']
point = ogr.Geometry(ogr.wkbPoint)
point.AddPoint(x,y)
point.Transform(coordTrans)
graph.node[node]['longitude'], graph.node[node]['latitude'] = point.GetX(), point.GetY()
return graph
评论列表
文章目录