iduedu.resolve_graph_edits

iduedu.resolve_graph_edits(graph, edits, *, tolerance=5.0, speed_kmh=None, min_coverage=0.5, node_ids='next', edge_types=None)[source]

Bind geometric edits to the current graph.

Anchors of remove and update select the edges that lie along them within tolerance; an edge covered only in part is split at the ends of the anchor, and only the covered part is changed. Crossing streets are not selected: the edge has to run along the anchor. Each end of an add line is attached to a node within tolerance, or splits the nearest edge within tolerance at the projection of the end, or becomes a new node. Split edges keep their attributes, with length and travel time shared out by length.

Edits that cannot be bound are skipped and reported instead of raising, so a stored scenario still applies after the graph is rebuilt.

Parameters:
  • graph (UrbanGraph) – Graph in a projected CRS; tolerance is in its units.

  • edits (GraphEdits) – Edits to bind.

  • tolerance (float) – Search distance for nodes and edges, in metres for the graphs of the builders.

  • speed_kmh (float | None) – Speed of added lines that have neither time_min nor speed_kmh.

  • min_coverage (float) – Least share of an anchor’s length that the selected edges must cover; an anchor with less is reported and skipped.

  • node_ids (Literal['next', 'coordinates']) – Ids of new nodes: "next" continues after the largest id of the graph, "coordinates" packs the coordinates as relabel_urban_graph() with by="coordinates" does.

  • edge_types (Iterable[str] | None) – Edit only edges whose type is one of these, and attach added lines only to their nodes, for example ["walk"] in an intermodal graph, so that a closed street does not remove the transit edges drawn along it.

Return type:

tuple[UrbanGraphChanges, DataFrame]

Returns:

Pair (changes, report). changes is applied with apply_urban_graph_changes(). report has a row per skipped edit: kind ("add", "remove" or "update"), edit (its index), reason and coverage (the share of an anchor covered by the graph).

Raises:
  • ValueError – If the graph CRS is missing or geographic, the parameters are out of range, or a new node id is already in the graph.

  • KeyError – If edge_types is given and the edges have no type column.