aequilibrae.project package#
Subpackages#
- aequilibrae.project.data package
- aequilibrae.project.network package
- Subpackages
- Submodules
- aequilibrae.project.network.connector_creation module
- aequilibrae.project.network.gmns_builder module
- aequilibrae.project.network.gmns_exporter module
- aequilibrae.project.network.haversine module
- aequilibrae.project.network.link module
- aequilibrae.project.network.link_type module
- aequilibrae.project.network.link_types module
- aequilibrae.project.network.links module
- aequilibrae.project.network.mode module
- aequilibrae.project.network.modes module
- aequilibrae.project.network.network module
- aequilibrae.project.network.node module
- aequilibrae.project.network.nodes module
- aequilibrae.project.network.osm_builder module
- aequilibrae.project.network.osm_downloader module
- aequilibrae.project.network.period module
- aequilibrae.project.network.periods module
- aequilibrae.project.network.safe_class module
- Module contents
Submodules#
aequilibrae.project.about module#
- class aequilibrae.project.about.About(project)#
Bases:
object
Provides an interface for querying and editing the about table of an AequilibraE project
>>> from aequilibrae import Project >>> project = Project.from_path("/tmp/test_project") # Adding a new field and saving it >>> project.about.add_info_field('my_super_relevant_field') >>> project.about.my_super_relevant_field = 'super relevant information' >>> project.about.write_back() # changing the value for an existing value/field >>> project.about.scenario_name = 'Just a better scenario name' >>> project.about.write_back()
- 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
- Arguments
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)
>>> from aequilibrae import Project >>> p = Project.from_path("/tmp/test_project") >>> p.about.add_info_field('a_cool_field') >>> p.about.a_cool_field = 'super relevant information' >>> p.about.write_back()
- write_back()#
Saves the information parameters back to the project database
>>> from aequilibrae import Project >>> p = Project.from_path("/tmp/test_project") >>> 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(project)#
Bases:
object
Basic resources used by all subclasses
- extent() shapely.geometry.polygon.Polygon #
Queries the extent of the layer 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
aequilibrae.project.data_loader module#
aequilibrae.project.database_connection module#
- aequilibrae.project.database_connection.database_connection(db_type: str, project_path=None) sqlite3.Connection #
aequilibrae.project.field_editor module#
- class aequilibrae.project.field_editor.FieldEditor(project, 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.from_path("/tmp/test_project") # 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
- add(field_name: str, description: str, data_type='NUMERIC') None #
Adds new field to the data table
- Arguments
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
Create Project#>>> newfile = Project() >>> newfile.new('/tmp/new_project')
Open Project#>>> from aequilibrae.project import Project >>> existing = Project() >>> existing.open('/tmp/test_project') >>> #Let's check some of the project's properties >>> existing.network.list_modes() ['M', 'T', 'b', 'c', 't', 'w'] >>> existing.network.count_links() 76 >>> existing.network.count_nodes() 24
- classmethod from_path(project_folder)#
- open(project_path: str) None #
Loads project from disk
- Arguments
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
- Arguments
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
Deprecated since version 0.7.0: Use
open()
instead.- Arguments
project_path (
str
): Full path to the project data folder. If the project inside does not exist, it will fail.
- connect()#
- activate()#
- deactivate()#
- log() aequilibrae.log.Log #
Returns a log object
allows the user to read the log or clear it
- property project_parameters: aequilibrae.parameters.Parameters#
- 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(project)#
aequilibrae.project.project_creation module#
- aequilibrae.project.project_creation.initialize_tables(project, db_type: str) None #
- aequilibrae.project.project_creation.create_base_tables(conn: sqlite3.Connection, logger: logging.Logger, db_type: str) None #
- aequilibrae.project.project_creation.add_triggers(conn: sqlite3.Connection, logger: logging.Logger, db_type: str) None #
Adds consistency triggers to the project
- aequilibrae.project.project_creation.remove_triggers(conn: sqlite3.Connection, logger: logging.Logger, db_type: str) None #
- aequilibrae.project.project_creation.run_queries_from_sql_file(conn: sqlite3.Connection, logger: logging.Logger, qry_file: str) None #
aequilibrae.project.table_loader module#
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
- 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
- Arguments
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, conn: Optional[sqlite3.Connection] = 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 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.
- 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 1
- disconnect_mode(mode_id: str) None #
Removes centroid connectors for the desired mode from the network file
- Arguments
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 >>> project = Project.from_path("/tmp/test_project") >>> zoning = project.zoning >>> zone_downtown = zoning.get(1) >>> zone_downtown.population = 637 >>> zone_downtown.employment = 10039 >>> zone_downtown.save() # changing the value for an existing value/field >>> project.about.scenario_name = 'Just a better scenario name' >>> project.about.write_back() # We can also add one more field to the table >>> fields = zoning.fields >>> fields.add('parking_spots', 'Total licensed parking spots', 'INTEGER')
- 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()#
- get_closest_zone(geometry: Union[shapely.geometry.point.Point, shapely.geometry.linestring.LineString, shapely.geometry.multilinestring.MultiLineString]) int #
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- Return
zone_id (
int
): ID of the zone applicable to the point provided
- refresh_geo_index()#