aequilibrae.project package

Subpackages

Submodules

aequilibrae.project.about module

class aequilibrae.project.about.About(conn: sqlite3.Connection)

Bases: object

Provides an interface for querying and editing the about table of an AequilibraE project

p = Project()
p.open('my/project/folder')
about = p.about

about.description = 'This is the example project. Do not use for forecast'
about.write_back()
__init__(conn: sqlite3.Connection)
create()

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

list_fields() list

Returns a list of all characteristics the about table holds

add_info_field(info_field: str) None

Adds new information field to the model

Args:

info_field (str): Name of the desired information field to be added. Has to be a valid Python VARIABLE name (i.e. letter as first character, no spaces and no special characters)

p = Project()
p.open('my/project/folder')
p.about.add_info_field('my_super_relevant_field')
p.about.my_super_relevant_field = 'super relevant information'
p.about.write_back()
write_back()

Saves the information parameters back to the project database

p = Project()
p.open('my/project/folder')
p.about.description = 'This is the example project. Do not use for forecast'
p.about.write_back()

aequilibrae.project.basic_table module

class aequilibrae.project.basic_table.BasicTable

Bases: object

Basic resources used by all subclasses

__init__()
extent() shapely.geometry.polygon.Polygon

Queries the extent of thelayer included in the model

Returns:

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

property fields: aequilibrae.project.field_editor.FieldEditor

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

refresh_connection()

Opens a new database connection to avoid thread conflict

aequilibrae.project.data_loader module

class aequilibrae.project.data_loader.DataLoader(conn: sqlite3.Connection, table_name: str)

Bases: object

__init__(conn: sqlite3.Connection, table_name: str)
load_table() pandas.core.frame.DataFrame

aequilibrae.project.database_connection module

aequilibrae.project.database_connection.database_connection() sqlite3.Connection

aequilibrae.project.field_editor module

class aequilibrae.project.field_editor.FieldEditor(table_name: str)

Bases: object

Allows user to edit the project data tables

The field editor is used for two different purposes:

  • Managing data tables (adding and removing fields)

  • Editing the tables’ metadata (description of each field)

This is a general class used to manage all project’s data tables accessible to the user and but it should be accessed directly from within the module corresponding to the data table one wants to edit. Example:

from aequilibrae import Project

proj = Project()
proj.open('Path/to/project/folder')

# To edit the fields of the link_types table
lt_fields = proj.network.link_types.fields

# To edit the fields of the modes table
m_fields = proj.network.modes.fields

Field descriptions are kept in the table attributes_documentation

__init__(table_name: str) None
add(field_name: str, description: str, data_type='NUMERIC') None

Adds new field to the data table

Args:

field_name (str): Field to be added to the table. Must be a valid SQLite field name description (str): Description of the field to be inserted in the metadata data_type (str, optional): Valid SQLite Data type. Default: “NUMERIC”

remove(field_name: str) None
save() None

Saves any field descriptions which my have been changed to the database

all_fields() List[str]

Returns the list of fields available in the database

aequilibrae.project.project module

class aequilibrae.project.project.Project

Bases: object

AequilibraE project class

from aequilibrae.project import Project

existing = Project()
existing.load('path/to/existing/project/folder')

newfile = Project()
newfile.new('path/to/new/project/folder')
__init__()
open(project_path: str) None

Loads project from disk

Args:

project_path (str): Full path to the project data folder. If the project inside does not exist, it will fail.

new(project_path: str) None

Creates a new project

Args:

project_path (str): Full path to the project data folder. If folder exists, it will fail

close() None

Safely closes the project

load(project_path: str) None

Loads project from disk

Args:

project_path (str): Full path to the project data folder. If the project inside does not exist, it will fail.

log() aequilibrae.log.log.Log

Returns a log object

allows the user to read the log or clear it

property matrices: aequilibrae.project.data.matrices.Matrices
property parameters: dict
check_file_indices() None

Makes results_database.sqlite and the matrices folder compatible with project database

property zoning

aequilibrae.project.project_cleaning module

aequilibrae.project.project_cleaning.clean()

aequilibrae.project.project_creation module

aequilibrae.project.project_creation.initialize_tables(conn: sqlite3.Connection) None
aequilibrae.project.project_creation.create_base_tables(conn: sqlite3.Connection) None
aequilibrae.project.project_creation.populate_meta_extra_attributes(conn: sqlite3.Connection) None
aequilibrae.project.project_creation.add_triggers(conn: sqlite3.Connection) None

Adds consistency triggers to the project

aequilibrae.project.project_creation.remove_triggers(conn: sqlite3.Connection) None
aequilibrae.project.project_creation.run_queries_from_sql_file(conn: sqlite3.Connection, qry_file: str) None

aequilibrae.project.spatialite_connection module

aequilibrae.project.spatialite_connection.spatialite_connection(conn: sqlite3.Connection) sqlite3.Connection

aequilibrae.project.table_loader module

class aequilibrae.project.table_loader.TableLoader

Bases: object

__init__()
load_table(curr: sqlite3.Cursor, table_name: str) List[dict]
load_structure(curr: sqlite3.Cursor, table_name: str) None

aequilibrae.project.zone module

class aequilibrae.project.zone.Zone(dataset: dict, zoning)

Bases: aequilibrae.project.network.safe_class.SafeClass

Single zone object that can be queried and manipulated in memory

__init__(dataset: dict, zoning)
delete()

Removes the zone from the database

save()

Saves/Updates the zone data to the database

add_centroid(point: shapely.geometry.point.Point, robust=True) None

Adds a centroid to the network file

Args:

point (Point): Shapely Point corresponding to the desired centroid position. If None, uses the geometric center of the zone robust (Bool, Optional): Moves the centroid location around to avoid node conflict. Defaults to True.

connect_mode(mode_id: str, link_types='', connectors=1) 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 zone.

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 zone, the search area is progressively expanded until at least one candidate is found.

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

Args:

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

disconnect_mode(mode_id: str) None

Removes centroid connectors for the desired mode from the network file

Args:

mode_id (str): Mode ID we are trying to disconnect from this zone

aequilibrae.project.zoning module

class aequilibrae.project.zoning.Zoning(network)

Bases: aequilibrae.project.basic_table.BasicTable

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

from aequilibrae import Project

p = Project()
p.open('path/to/project/folder')

zones = p.zoning

# We edit the fields for a particular zone
zone_downtown = zones.get(1)
zone_downtown.population = 637
zone_downtown.employment = 10039
zone_downtown.save()

fields = zones.fields

# We can also add one more field to the table
fields.add('parking_spots', 'Total licensed parking spots', 'INTEGER')
__init__(network)
new(zone_id: int) aequilibrae.project.zone.Zone

Creates a new zone

Returns:

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

create_zoning_layer()

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

coverage() shapely.geometry.polygon.Polygon

Returns a single polygon for the entire zoning coverage

Returns:

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

get(zone_id: str) aequilibrae.project.zone.Zone

Get a zone from the model by its zone_id

all_zones() dict

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

save()

Module contents