aequilibrae.utils package#
Submodules#
aequilibrae.utils.create_delaunay_network module#
- class aequilibrae.utils.create_delaunay_network.DelaunayAnalysis(project)#
Bases:
object- create_network(source='zones', overwrite=False)#
Creates a delaunay network based on the existing model
- Arguments:
source (
str, optional): Source of the centroids/zones. Eitherzonesornetwork. Defaultzonesoverwrite path (
bool, optional): Whether to should overwrite an existing Delaunay Network. DefaultFalse
- assign_matrix(matrix: AequilibraeMatrix, result_name: str)#
aequilibrae.utils.create_example module#
- aequilibrae.utils.create_example.create_example(path: str, from_model='sioux_falls') Project#
Copies an example model to a new project project and returns the project handle
- Arguments:
path (
str): Path where to create a new model. must be a non-existing folder/directory. from_model (str, Optional): Example to create from sioux_falls, nauru or coquimbo. Defaults to sioux_falls- Returns:
project (
Project): Aequilibrae Project handle (open)
aequilibrae.utils.db_utils module#
- aequilibrae.utils.db_utils.list_tables_in_db(conn: Connection)#
- aequilibrae.utils.db_utils.safe_connect(filepath: PathLike, missing_ok=False)#
- aequilibrae.utils.db_utils.normalise_conn(curr: Cursor | Connection | PathLike)#
- class aequilibrae.utils.db_utils.commit_and_close(db: str | Path | Connection, commit: bool = True, missing_ok: bool = False)#
Bases:
objectA context manager for sqlite connections which closes and commits.
- aequilibrae.utils.db_utils.read_and_close(filepath)#
A context manager for sqlite connections (alias for commit_and_close(db,commit=False)).
- aequilibrae.utils.db_utils.read_sql(sql, filepath, **kwargs)#
- aequilibrae.utils.db_utils.has_table(conn, table_name)#
- class aequilibrae.utils.db_utils.ColumnDef(idx: int, name: str, type: str, not_null: bool, default: str, is_pk: bool)#
Bases:
object- idx: int#
- name: str#
- type: str#
- not_null: bool#
- default: str#
- is_pk: bool#
- aequilibrae.utils.db_utils.get_schema(conn, table_name)#
- aequilibrae.utils.db_utils.has_column(conn, table_name, col_name)#
- aequilibrae.utils.db_utils.add_column_unless_exists(conn, table_name, col_name, col_type, constraints=None)#
- aequilibrae.utils.db_utils.add_column(conn, table_name, col_name, col_type, constraints=None)#
aequilibrae.utils.geo_index module#
- class aequilibrae.utils.geo_index.GeoIndex#
Bases:
objectImplements a generic GeoIndex class that uses the QGIS index when using the GUI and RTree otherwise
- build_from_layer(layer) dict#
- insert(feature_id: int, geometry: Point | Polygon | LineString | MultiPoint | MultiPolygon | MultiLineString) None#
Inserts a valid shapely geometry in the index
- Arguments:
feature_id (
int): ID of the geometry being inserted geo (Shapely.geometry): Any valid shapely geometry
- nearest(geo: Point | Polygon | LineString | MultiPoint | MultiPolygon, num_results) List[int]#
Finds nearest neighbor for a given geometry
- Arguments:
geo (
Shapely geometry): Any valid shapely geometry num_results (int): A positive integer for the number of neighbors to return- Return:
neighbors (
List[int]): List of IDs of the closest neighbors in the index
- delete(feature_id, geometry: Point | Polygon | LineString | MultiPoint | MultiPolygon)#
- reset()#
aequilibrae.utils.get_table module#
- aequilibrae.utils.get_table.get_table(table_name, conn)#
Selects table from database.
- Arguments:
table_name (
str): desired table name conn (sqlite3.Connection): database connection
aequilibrae.utils.list_tables_in_db module#
- aequilibrae.utils.list_tables_in_db.list_tables_in_db(conn)#
Return a list with all tables within a database.
- Arguments:
conn (:obj: sqlite3.Connection): database connection
aequilibrae.utils.qgis_utils module#
aequilibrae.utils.spatialite_utils module#
- aequilibrae.utils.spatialite_utils.is_windows()#
- aequilibrae.utils.spatialite_utils.is_not_windows()#
- aequilibrae.utils.spatialite_utils.connect_spatialite(path_to_file: PathLike, missing_ok: bool = False) Connection#
- aequilibrae.utils.spatialite_utils.is_spatialite(conn)#
- aequilibrae.utils.spatialite_utils.ensure_spatialite_binaries(directory: PathLike | None = None) None#
- aequilibrae.utils.spatialite_utils.spatialize_db(conn, logger=None)#
aequilibrae.utils.worker_thread module#
Original Author: UNKNOWN. COPIED FROM STACKOVERFLOW BUT CAN’T REMEMBER EXACTLY WHERE