File name
Commit message
Commit date
2023-10-24
2023-10-24
2023-10-24
File name
Commit message
Commit date
2023-10-24
from database.database import DB
import pandas as pd
import networkx as nx
from itertools import tee
def pairwise( iterable ):
"""Returns an iterable access binary tuple
s -> (s0,s1), (s1,s2), (s2, s3), ..."""
a, b = tee( iterable )
next(b, None)
return zip(a, b)
def swith_xy(tuples):
x,y=tuples
return (y,x)
db=DB()
df=pd.DataFrame(db.db_get_node())
df.columns=['index','source_x','source_y','target_x','target_y','distance']
G=nx.Graph()
for j in range(len(df)):
G.add_edge((df['source_x'][j],df['source_y'][j]),(df['target_x'][j],df['target_y'][j]),length=df['distance'][j])
nx.write_gpickle(G,'OSM_gpickle.gpickle')