Skip to content

API Docs

Main Functions

Parse a GeoJSON or KML AOI into a normalized FeatureCollection of Polygons.

Non-Polygon geometries are skipped with a UserWarning.

Parameters:

Name Type Description Default
db str | Connection

Existing db connection, or connection string.

required
geojson_raw str | bytes | dict

GeoJSON or KML file path, string or file bytes, or a GeoJSON dict.

required
merge bool

Merge all Polygons into a single Polygon, without holes. Disjoint Polygons are joined by their convex hull.

False

Returns:

Name Type Description
FeatureCollection FeatureCollection

a FeatureCollection of Polygons.

Raises:

Type Description
ValueError

If the input is invalid or contains no Polygons.

Parse a GeoJSON or KML AOI into a normalized FeatureCollection of Polygons.

Non-Polygon geometries are skipped with a UserWarning.

Parameters:

Name Type Description Default
db str | AsyncConnection

Existing db connection, or connection string.

required
geojson_raw str | bytes | dict

GeoJSON or KML file path, string or file bytes, or a GeoJSON dict.

required
merge bool

Merge all Polygons into a single Polygon, without holes. Disjoint Polygons are joined by their convex hull.

False

Returns:

Name Type Description
FeatureCollection FeatureCollection

a FeatureCollection of Polygons.

Raises:

Type Description
ValueError

If the input is invalid or contains no Polygons.

Helpers

Database config for Postgres.

Allows overriding values via constructor parameters, fallback to env vars.

Attributes:

Name Type Description
dbname str

Database name.

user str

Database user.

password str

Database password.

host str

Database host.

port int

Database port.

__post_init__()

Read env vars at runtime, not at class definition.

get_connection_string()

Connection string that psycopg accepts.