I have created the following function to take Origin = str, Destination = str, line = shapely.geometry.linestring.LineString, node = GeoDataFrame
def create_lines_df(Origin, Destination, line_, nodes_):
line_dfs = gpd.GeoDataFrame()
dict_ = [{'Origin':Origin,'Destination':Destination,'geometry':line_,
'length':line_.length,
'osmid':[nodes_.index.values]}]
df = gpd.GeoDataFrame(dict_, geometry='geometry', crs=oslo_edges_proj.crs)
line_dfs = line_dfs.append(df, ignore_index=True)
and the goal is to return a geodataframe but the result geodataframe is empty, although when I change line_dfs to a list it does correctly return the result I want but in a list.
What do I need to change?
Edited the above code to be:
gamle_dfs = []
def create_lines_df_2(Origin, Destination, line_, nodes_):
dict_ = [{'Origin':Origin,'Destination':Destination,'geometry':line_,
'length':line_.length,
'osmid':[nodes_.index.values]}]
df = gpd.GeoDataFrame(dict_, geometry='geometry', crs=oslo_edges_proj.crs)
gamle_dfs.append(df)
Now I have a list of dataframes that I can't extract. Any recommendations?