geometry
Functions
aws_locator
def aws_locator(pair: tuple | list) -> dict
Function to perform reverse geocoding to collect address information using AWS Locations.
Arguments:
pairtuple | list - Input coordinate pair, use normal lat long format.
Raises:
Exception- reverse geocoding was impossible
Returns:
dict- object contains address information like Street and Number.
Examples:
aws_locator(
pair=[1.0, 1.0]
)
clean_geom
def clean_geom(workspace: str,
layername: str,
connection,
column: str = "geom") -> None
Function to clean empty geometries from table
Arguments:
workspacestr - Input name of workspace.layernamestr - Input layer name.connection(psycopg2.connection()) - database connection.columnstr, optional - name of the column to check. Defaults to "geom".
Returns:
None
data_uploader
def data_uploader(workspace: str,
layername: str,
data: List[dict],
connection,
template: str = "") -> None
Function to wreck database tables. This one leverages execute_values() to insert tons
of rows in 1 transaction. The function is aimed for data uploads and will skip any
geom attributes.
Arguments:
workspacestr - Input name of workspace.layernamestr - Input layer name.dataList[dict] - array containing dictionaries keys are the column names and values the, well, values.connection(psycopg2.connection()) - database connection.templatestr, optional - Input alphabetically ordered column names to resolve theexecute_many()check examples on its format. Defaults to"".
Examples:
data_uploader(
workspace="opusinsights_1_nld_1",
layername="contourlines",
data=[
{"foo": 1, "bar": "test"},
{"foo": 3, "bar": "test2"}
],
connection=connection(),
template="(%(date)s, %(elev)s, %(uid)s, %(wkt)s)"
)
upload_geom
def upload_geom(workspace: str,
layername: str,
connection,
crs: int,
date: str,
wkt: str = "",
on_premise: bool = True,
drop_wkt: bool = True,
id_column: str = "id") -> None
Function to upload geometry to a PostGIS enabled PostgreSQL database
Arguments:
workspacestr - Input name of workspace.layernamestr - Input layer name.connection(psycopg2.connection()) - database connection.crsint - Input CRS as integer (EPSG:4326 -> 4326).datestr - Input date of geometry to handle constrained updates.wktstr, optional - Input Well Known Text, mutually exclusive withon_premise. Defaults to"".on_premisebool, optional - Switch to create geometries on existing WKT attribute in table mutually exclusive with wkt. Defaults toTrue.drop_wktbool, optional - Drop the WKT string in the table after uploading, will skip if WKT is not present in table. Defaults toTrue.id_columnstr, optional - ID column used to count the number of rows. Defaults to"id".
Examples:
upload_geom(
workspace="opusinsights_1_nld_1",
layername="contourlines",
date="2021-01-01",
connection=DB_connection,
crs=4326,
wkt="POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))",
on_premise=False,
drop_wkt=False
)
This example only works when attribute geom in present in table.
upload_geom(
workspace="opusinsights_1_nld_1",
layername="contourlines",
date="2021-01-01",
connection=DB_connection,
crs=4326,
wkt="",
on_premise=True,
drop_wkt=True,
id_column="id_0"
)