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) >>> 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') >>> project.close()
Methods
__init__
(network)add_centroids
([robust])Adds automatic centroids to the network file.
Returns a dictionary with all Zone objects available in the model, using
zone_id
as keyconnect_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
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
save
()Attributes
Returns all zones data as a Pandas DataFrame
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 toTrue
.
- 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 connectlink_types (
str
, Optional): String with all the link type IDs that can be considered. eg: yCdR. Defaults to ALL link typesconnectors (
int
, Optional): Number of connectors to add. Defaults to 1limit_to_zone (
bool
): Limits the search for nodes inside the zone. Defaults toTrue
.
- 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_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
orLineString
): 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 withzone_id
(but not saved in the model yet)
- 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