// extract the edges" endpoint nodes" coordinates
try:
coords = (
(u, v, k, G.nodes[u]["y"], G.nodes[u]["x"], G.nodes[v]["y"], G.nodes[v]["x"])
for u, v, k in G.edges
)
except KeyError: // pragma: no cover
missing_nodes = {
str(i)
for u, v, _ in G.edges(keys=True)
if not (G.nodes[u] or G.nodes[u])
for i in (u, v)
if not G.nodes[i]
}
missing_str = ", ".join(missing_nodes)
raise KeyError(f"Edge(s) missing nodes {missing_str} possibly due to clipping issue")
// turn the coordinates into a DataFrame indexed by u, v, k
cols = ["u", "v", "k", "u_y", "u_x", "v_y", "v_x"]
df = pd.DataFrame(coords, columns=cols).set_index(["u", "v", "k"])
// calculate great circle distances, fill nulls with zeros, then round
dists = distance.great_circle_vec(df["u_y"], df["u_x"], df["v_y"], df["v_x"])