Is there any way to add parallel offset for those lines which oneway road are False? All line here are straight (segment). So We just have two points for each line (start and end points).
# There is 43 857 edges with 14 561 oneway roads and 29 296 bi-
directionals roads
G = nx.from_pandas_edgelist(edges,'origin', 'destination',
['key','id_edge', 'name', 'lanes','length', 'speed',
'capacity', 'function', 'geometry'],
create_using=nx.MultiDiGraph)
# Add nodes to the graph G
data = nodes.set_index('id_node').to_dict('index').items()
G.add_nodes_from(data)
# Add oneway column (it will be a boolean)
for u,v,d in G.edges(keys=False, data=True):
if G.has_edge(v,u):
G.edges[u,v,0]['oneway'] = False
else:
G.edges[u,v,0]['oneway'] = True
m = folium.Map(location=[48.86088, 2.33765], zom_start=2)
folium.features.GeoJson(edges).add_to(m)
To have parallel side, I tried this :
points = []
for u,v,data in G.edges(keys=False, data=True):
if 'geometry' in data:
xs,ys = data['geometry'].xy
point = list(zip(xs,ys))
if not data['oneway']:
points.append(point)
gdf = gpd.GeoDataFrame({'geometry': [LineString(l) for l in points] })
gdf.set_geometry('geometry', inplace=True) # set the geometry
gdf.set_crs('EPSG:4326', inplace=True) # set the actual CRS
gdf1 = gdf['geometry'].apply(lambda x:x.parallel_offset(0.6, 'left', 2)
m = folium.Map(location=[48.86088, 2.33765], zom_start=2)
folium.features.GeoJson(edges).add_to(m)
folium.Choropleth(gdf1,line_weight=1,line_color='red').add_to(m)

