Dmitriy Tarasov
unread,Oct 15, 2021, 4:04:33 PM10/15/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to geopandas
I have a shapefile of points that I need to add to a graph (representing a road network) as new nodes. I read the nodes from the shapefile to a GeoDataFrame (let's call it "incidents") and try to add them to the graph as follows:
import osmnx as ox
...
for index, row in incidents.iterrows():
incident_coords = (row["Latitude"], row["Longitude"])
incident_node_id = ox.get_nearest_node(graph_proj, incident_coords, method="euclidean") #finds the nearest existing node on my graph, graph_proj
incident_node = nodes_proj.loc[incident_node_id]
incident_node_t = tuple(incident_node)
graph_proj.add_edge(incident_coords, incident_node_t)
This last line, however, throws an error, saying, "unhashable type: 'Point'". I tried to ensure that both of the inputs to add_edge are hashable (tuples, in this case). My question is, what is the syntax, when working with geographic information, for adding a pair of coordinates from a GeoDataFrame to a graph as a new node? Thanks everyone for any advice on this.