aequilibrae.project.Zoning#

class aequilibrae.project.Zoning(network)[source]#

Access to the API resources to manipulate the ‘zones’ table in the project

>>> project = create_example(project_path, "coquimbo")

>>> zoning = project.zoning

>>> zone_downtown = zoning.get(1)
>>> zone_downtown.population = 637
>>> zone_downtown.employment = 10039
>>> zone_downtown.save()

# We can also add one more field to the table
>>> fields = zoning.fields
>>> fields.add('parking_spots', 'Total licensed parking spots', 'INTEGER')
__init__(network)[source]#

Methods

__init__(network)

add_centroids([robust])

Adds automatic centroids to the network file.

all_zones()

Returns a dictionary with all Zone objects available in the model, using zone_id as key

connect_mode(mode_id[, link_types, ...])

Adds centroid connectors for the desired mode to the network file

coverage()

Returns a single polygon for the entire zoning coverage

create_zoning_layer()

Creates the 'zones' table for project files that did not previously contain it

extent()

Queries the extent of the layer included in the model

get(zone_id)

Get a zone from the model by its zone_id

get_closest_zone(geometry)

Returns the zone in which the given geometry is located.

new(zone_id)

Creates a new zone

refresh_geo_index()

save()

Attributes

data

Returns all zones data as a Pandas DataFrame

fields

Returns a FieldEditor class instance to edit the zones table fields and their metadata

add_centroids(robust=True)[source]#

Adds automatic centroids to the network file. It adds centroids to all zones that do not have one Centroid is added to the geographic centroid of the zone.

Arguments:

robust (bool, Optional): Moves the centroid location around to avoid node conflict. Defaults to True.

all_zones() dict[source]#

Returns a dictionary with all Zone objects available in the model, using zone_id as key

connect_mode(mode_id: str, link_types='', connectors=1, limit_to_zone=True)[source]#

Adds centroid connectors for the desired mode to the network file

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

The selection of the nodes that will be connected is done simply by searching for the node closest to each zone centroid, or the N closest nodes to the centroid.

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

CENTROIDS THAT ARE CURRENTLY CONNECTED ARE SKIPPED ALTOGETHER

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

limit_to_zone (bool): Limits the search for nodes inside the zone. Defaults to True.

coverage() Polygon[source]#

Returns a single polygon for the entire zoning coverage

Returns:

model coverage (Polygon): Shapely (Multi)polygon of the zoning system.

create_zoning_layer()[source]#

Creates the ‘zones’ table for project files that did not previously contain it

extent() Polygon#

Queries the extent of the layer included in the model

Returns:

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

get(zone_id: str) Zone[source]#

Get a zone from the model by its zone_id

get_closest_zone(geometry: Point | LineString | MultiLineString) int[source]#

Returns the zone in which the given geometry is located.

If the geometry is not fully enclosed by any zone, the zone closest to the geometry is returned

Arguments:

geometry (Point or LineString): A Shapely geometry object

Returns:

zone_id (int): ID of the zone applicable to the point provided

new(zone_id: int) Zone[source]#

Creates a new zone

Returns:

zone (Zone): A new zone object populated only with zone_id (but not saved in the model yet)

refresh_geo_index()[source]#
save()[source]#
property data: GeoDataFrame#

Returns all zones data as a Pandas DataFrame

Returns:

table (GeoDataFrame): GeoPandas GeoDataFrame with all the nodes

property fields: FieldEditor#

Returns a FieldEditor class instance to edit the zones table fields and their metadata