Skip to main content
`Ctrl`+`K`

# aequilibrae.project.network.Node

class aequilibrae.project.network.Node(dataset, project)

  A Node object represents a single record in the nodes table

      >>> from shapely.geometry import Point

      >>> project = create_example(project_path)

      >>> all_nodes = project.network.nodes

      # We can just get one link in specific
      >>> node1 = all_nodes.get(7)

      # We can find out which fields exist for the links
      >>> which_fields_do_we_have = node1.data_fields()

      # It success if the node_id already does not exist
      >>> node1.renumber(998877)

      >>> node1.geometry = Point(1,2)

      # We can just save the node
      >>> node1.save()

  __init__(dataset, project)

  Methods

  `__init__`(dataset, project) |
  `connect_db`() |
  `connect_mode`(mode_id[, link_types, ...]) | Adds centroid connectors for the desired mode to the network file
  `data_fields`() | lists all data fields for the node, as available in the database
  `renumber`(new_id) | Renumbers the node in the network
  `save`() | Saves node to database

  connect_db()
  connect_mode(mode_id: str, link_types='', connectors=1, conn: Connection | None = None, area: Polygon | None = None)

    Adds centroid connectors for the desired mode to the network file

    Centroid connectors are created by connecting the zone centroid to one or more nodes selected from all those that satisfy the mode and link_types criteria and are inside the provided area.

    The selection of the nodes that will be connected is done simply by computing running the KMeans2 clustering algorithm from SciPy and selecting the nodes closest to each cluster centroid.

    When there are no node candidates inside the provided area, is it progressively expanded until at least one candidate is found.

    If fewer candidates than required connectors are found, all candidates are connected.

    Arguments:

      mode_id (`str`): Mode ID we are trying to connect

      link_types (`str`, Optional): String with all the link type IDs that can be considered. eg: yCdR. Defaults to ALL link types

      connectors (`int`, Optional): Number of connectors to add. Defaults to 1

      area (`Polygon`, Optional): Area limiting the search for connectors

  data_fields() → list

    lists all data fields for the node, as available in the database

    Returns:

      data fields (`list`): list of all fields available for editing

  renumber(new_id: int)

    Renumbers the node in the network

    Logs a warning if another node already exists with this node_id

    Arguments:

      new_id (`int`): New node_id

  save()

    Saves node to database