forked from manelone/Walk-This-Way
-
Notifications
You must be signed in to change notification settings - Fork 0
/
st_edges.py
32 lines (23 loc) · 856 Bytes
/
st_edges.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pandas import pandas as pd
stEdges = pd.read_csv("cal.cedge.csv")
stNodes = pd.read_csv("cal.cnode.csv")
print "COLUMNS FOR EDGES: ", stEdges.columns
print "COLUMNS FOR NODES: ", stNodes.columns
startCoords = []
endCoords = []
nodes = stNodes.as_matrix()
for i, edge in stEdges.iterrows():
# print edge
# print edge['startID'], edge['endID']
start = int(edge['startID'])
end = int(edge['endID'])
startCoords.append((float(nodes[start][2]), float(nodes[start][1])))
endCoords.append((float(nodes[end][2]), float(nodes[end][1])))
#print edge['NodeID']
# which st['NodeID'] == startID
startCoords = pd.Series(startCoords, name='startCoords')
endCoords = pd.Series(endCoords, name='endCoords')
#print startCoords
df = pd.concat([stEdges['EdgeID'], startCoords, endCoords, stEdges['distance']], axis=1)
# print df
df.to_csv("edgeLocs.csv")