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. Eitherzones
ornetwork
. Defaultzones
overwrite path (
bool
, optional): Whether to should overwrite an existing Delaunay Network. DefaultFalse
- assign_matrix(matrix: aequilibrae.matrix.aequilibrae_matrix.AequilibraeMatrix, result_name: str)#
aequilibrae.utils.create_example module#
- aequilibrae.utils.create_example.create_example(path: str, from_model='sioux_falls') aequilibrae.project.project.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: sqlite3.Connection)#
- aequilibrae.utils.db_utils.safe_connect(filepath: os.PathLike, missing_ok=False)#
- class aequilibrae.utils.db_utils.commit_and_close(db: Union[str, pathlib.Path, sqlite3.Connection], commit: bool = True, missing_ok: bool = False)#
Bases:
object
A 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:
object
Implements 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: Union[shapely.geometry.point.Point, shapely.geometry.polygon.Polygon, shapely.geometry.linestring.LineString, shapely.geometry.multipoint.MultiPoint, shapely.geometry.multipolygon.MultiPolygon, shapely.geometry.multilinestring.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: Union[shapely.geometry.point.Point, shapely.geometry.polygon.Polygon, shapely.geometry.linestring.LineString, shapely.geometry.multipoint.MultiPoint, shapely.geometry.multipolygon.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: Union[shapely.geometry.point.Point, shapely.geometry.polygon.Polygon, shapely.geometry.linestring.LineString, shapely.geometry.multipoint.MultiPoint, shapely.geometry.multipolygon.MultiPolygon])#
- reset()#
aequilibrae.utils.geo_utils module#
Convenience functions for working with geospatial data.
- aequilibrae.utils.geo_utils.haversine(lon1, lat1, lon2, lat2)#
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
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: os.PathLike, missing_ok: bool = False) sqlite3.Connection #
- aequilibrae.utils.spatialite_utils.is_spatialite(conn)#
- aequilibrae.utils.spatialite_utils.ensure_spatialite_binaries(directory: Optional[os.PathLike] = 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