Skip to content

Add functionality to create centroids and centroid connector to model network#478

Draft
lmz wants to merge 251 commits into
network-wrangler:mainfrom
BayAreaMetro:centroids
Draft

Add functionality to create centroids and centroid connector to model network#478
lmz wants to merge 251 commits into
network-wrangler:mainfrom
BayAreaMetro:centroids

Conversation

@lmz

@lmz lmz commented Jun 19, 2026

Copy link
Copy Markdown
Member

This PR adds end-to-end support for creating centroids and centroid connectors in a model network, including the core APIs, geometry/link generation logic, and tests/documentation updates needed to use and validate the workflow.

What this PR does

This PR introduces functionality to build model-zone access structures by generating:

  • Centroid nodes (zone representation in the network)
  • Centroid connector links between centroids and nearby network nodes
  • The feature is designed to support common modeling workflows where zones/TAZs need to be integrated into the routable network with generated access/egress links.

Key changes

  • Added APIs/utilities to create centroid nodes from input zone geometry/data.
  • Added logic to create centroid connector links from each centroid to eligible nearby network nodes.
  • Added validation and guardrails around connector creation inputs and outputs.
  • Added/updated tests covering centroid and connector creation behavior.
  • Updated docs/examples to demonstrate expected usage and outputs.

Why this change is needed

Many demand and assignment workflows require zone-level connectors to represent how trips enter/exit the physical network. This PR provides a native, repeatable way to generate those structures directly in network_wrangler, reducing manual preprocessing and ensuring consistent connector generation behavior.

Implementation notes

Centroid generation and connector generation are implemented as explicit network-building operations so they can be run as part of a reproducible wrangling pipeline.
Connector creation is based on proximity/eligibility rules to attach centroids to nearby nodes.
The new functionality is intended to be configurable for model-specific connector policies.

Testing

  • This PR includes tests for:
  • Correct centroid creation from valid inputs
  • Connector generation for expected nearest/eligible nodes
  • Error/edge handling for invalid or missing inputs
  • Basic integrity checks on produced nodes/links
  • Backward compatibility
  • Existing workflows are unaffected unless the new centroid/connector functionality is explicitly invoked.
  • No breaking changes are intended for users not using these new APIs.

Limitations / follow-ups

Connector selection policies may still need tuning for specific model conventions (e.g., max connectors per zone, facility/type filtering, directional behavior).
Future enhancements can expand configurability and performance for very large zone sets.


lmz added 30 commits June 17, 2025 11:14
Moving API detail to API_*.md
lmz and others added 29 commits January 26, 2026 12:58
- Fix TypeError 'Series object is not callable' in match_bus_stops_to_roadway_nodes
  (missing & operator, extra parens treating boolean Series as a function call)
- Fix unhashable type error in add_additional_data_to_stops by converting
  Categorical route_type column to int before groupby aggregation
- Relax TripsTable.shape_id to nullable=True (shape_id is optional per GTFS spec)
- Add Union import to io_table.py

Not centroid-branch related; applies to any use of transit network creation.
@lmz lmz marked this pull request as draft June 19, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants