Skip to main content
`Ctrl`+`K`

# aequilibrae.project.Network

class aequilibrae.project.Network(project)

  Network class. Member of an AequilibraE Project

  __init__(project) → None

  Methods

  `__init__`(project) |
  `build_graphs`([fields, modes]) | Builds graphs for all modes currently available in the model
  `convex_hull`() | Queries the model for the convex hull of the entire network
  `count_centroids`() | Returns the number of centroids in the model
  `count_links`() | Returns the number of links in the model
  `count_nodes`() | Returns the number of nodes in the model
  `create_from_gmns`(link_file_path, node_file_path) | Creates AequilibraE model from links and nodes in GMNS format.
  `create_from_osm`([model_area, place_name, ...]) | Downloads the network from OpenStreetMap (OSM)
  `export_to_gmns`(path) | Exports AequilibraE network to csv files in GMNS format.
  `extent`() | Queries the extent of the network included in the model
  `list_modes`() | Returns a list of all the modes in this model
  `set_time_field`(time_field) | Set the time field for all graphs built in the model
  `skimmable_fields`() | Returns a list of all fields that can be skimmed

  Attributes

  `link_types` |
  `protected_fields` |
  `req_link_flds` |
  `req_node_flds` |
  `signal` |

  build_graphs(fields: list | None = None, modes: list | None = None) → None

    Builds graphs for all modes currently available in the model

    When called, it overwrites all graphs previously created and stored in the networks’ dictionary of graphs

    Arguments:

      fields (`list`, Optional): When working with very large graphs with large number of fields in the database, it may be useful to specify which fields to use

      modes (`list`, Optional): When working with very large graphs with large number of fields in the database, it may be useful to generate only those we need

    To use the ‘fields’ parameter, a minimalistic option is the following

        >>> project = create_example(project_path)

        >>> fields = ['distance']
        >>> project.network.build_graphs(fields, modes = ['c', 'w'])

  convex_hull() → Polygon

    Queries the model for the convex hull of the entire network

    Returns:

      model coverage (`Polygon`): Shapely (Multi)polygon of the model network.

  count_centroids() → int

    Returns the number of centroids in the model

    Returns:

      `int`: Number of centroids

  count_links() → int

    Returns the number of links in the model

    Returns:

      `int`: Number of links

  count_nodes() → int

    Returns the number of nodes in the model

    Returns:

      `int`: Number of nodes

  create_from_gmns(link_file_path: str, node_file_path: str, use_group_path: str | None = None, geometry_path: str | None = None, srid: int = 4326) → None

    Creates AequilibraE model from links and nodes in GMNS format.

    Arguments:

      link_file_path (`str`): Path to a links csv file in GMNS format

      node_file_path (`str`): Path to a nodes csv file in GMNS format

      use_group_path (`str`, Optional): Path to a csv table containing groupings of uses. This helps AequilibraE know when a GMNS use is actually a group of other GMNS uses

      geometry_path (`str`, Optional): Path to a csv file containing geometry information for a line object, if not specified in the link table

      srid (`int`, Optional): Spatial Reference ID in which the GMNS geometries were created

  create_from_osm(model_area: Polygon | None = None, place_name: str | None = None, modes=('car', 'transit', 'bicycle', 'walk'), clean=True) → None

    Downloads the network from OpenStreetMap (OSM)

    Arguments:

      area (`Polygon`, Optional): Polygon for which the network will be downloaded. If not provided, a place name would be required

      place_name (`str`, Optional): If not downloading with East-West-North-South boundingbox, this is required

      modes (`tuple`, Optional): List of all modes to be downloaded. Defaults to the modes in the parameter file

      clean (`bool`, Optional): Keeps only the links that intersects the model area polygon. Defaults to `True`. Does not apply to networks downloaded with a place name

        >>> project = Project()
        >>> project.new(project_path)

        # Now we can import the network for any place we want
        >>> project.network.create_from_osm(place_name="my_beautiful_hometown")

        >>> project.close()

  export_to_gmns(path: str)

    Exports AequilibraE network to csv files in GMNS format.

    Arguments:

      path (`str`): Output folder path.

  extent()

    Queries the extent of the network included in the model

    Returns:

      model extent (`Polygon`): Shapely polygon with the bounding box of the model network.

  list_modes()

    Returns a list of all the modes in this model

    Returns:

      `list`: List of all modes

  set_time_field(time_field: str) → None

    Set the time field for all graphs built in the model

    Arguments:

      time_field (`str`): Network field with travel time information

  skimmable_fields()

    Returns a list of all fields that can be skimmed

    Returns:

      `list`: List of all fields that can be skimmed

  link_types: LinkTypes = None
  protected_fields = ['ogc_fid', 'geometry']
  req_link_flds = ['link_id', 'a_node', 'b_node', 'direction', 'distance', 'modes', 'link_type']
  req_node_flds = ['node_id', 'is_centroid']
  signal = <aequilibrae.utils.python_signal.PythonSignal object>