DuckGL GitHub ↗

Embedded Python API

Use typed arguments with a DuckDB connection configured by your application.

View the Python source

PublishedLayer

Publish a host-selected main-schema relation for the lifetime of a with block.

  • __init__(self, connection: DuckDBPyConnection, view: str)

Viewport

  • west: float
  • south: float
  • east: float
  • north: float

TimeRange

A half-open interval of absolute instants.

  • start: datetime
  • end: datetime

MapPoint

  • feature_id: int
  • longitude: float
  • latitude: float
  • label: str | None

GridCell

  • x: int
  • y: int
  • count: int
  • longitude: float
  • latitude: float

SelectionStatistics

  • count: int
  • total: float | int | None

FilterOperator

  • EQ = '='
  • NE = '<>'
  • LT = '<'
  • LE = '<='
  • GT = '>'
  • GE = '>='
  • IS_NULL = 'IS NULL'
  • IS_NOT_NULL = 'IS NOT NULL'

AttributeColumn

Column name and value type registered by the application host.

  • name: str
  • value_type: type

AttributeFilter

  • column_id: str
  • operator: FilterOperator
  • value: str | int | float | bool | None = None

AllOf

  • terms: tuple['FilterSpec', ...]

AnyOf

  • terms: tuple['FilterSpec', ...]

PointLayer

Read WGS84 points from a trusted host-selected main-schema relation. The host provisions a tenant-scoped connection and a primary/unique feature_id. Longitudes in the source use the [-180, 180] convention.

  • __init__(self, connection: DuckDBPyConnection, relation: str, *, attributes=None, time_column: str | None=None, catalog: str | None=None)
  • fetch(self, viewport: Viewport, *, where: FilterSpec | None=None, time: TimeRange | None=None) → list[MapPoint]
  • fetch_at_zoom(self, viewport: Viewport, zoom: int, *, where: FilterSpec | None=None, time: TimeRange | None=None) → list[GridCell] | list[MapPoint]

    Use a world-aligned degree grid below zoom 14 and points at higher zoom.

  • polygon_statistics(self, ring: tuple[tuple[float, float], ...], *, sum_attribute: str | None=None) → SelectionStatistics

    Aggregate original point coordinates inside a closed WGS84 selection ring.

BoundaryAssignment

  • ALL_MATCHES = 'all_matches'
  • LOWEST_ID = 'lowest_id'

RegionCounts

  • region_counts: tuple[tuple[int, int], ...]
  • unmatched: int
  • no_position: int

RegionalStatistics

Count registered, same-CRS points in regions using inclusive polygon boundaries.

  • __init__(self, connection: DuckDBPyConnection, points: str, regions: str)
  • count(self, assignment: BoundaryAssignment) → RegionCounts

GeometryFeature

  • feature_id: int
  • geometry: dict
  • attributes: dict

GeometryLayer

Project registered geometry attributes and select features by a WGS84 viewport.

  • __init__(self, connection: DuckDBPyConnection, relation: str, *, source_crs: str, attributes: Mapping[str, str] | None=None, catalog: str | None=None)
  • fetch(self, viewport: Viewport) → list[GeometryFeature]

    Return each matching ID once, including shapes that touch an edge.

  • fetch_clipped(self, viewport: Viewport, *, buffer_degrees: float=0) → list[GeometryFeature]

    Return display geometry clipped to the viewport plus its optional angular buffer.

LayerId

  • value: str

RegisteredLayer

  • catalog: str
  • relation: str
  • version: str
  • attributes: Mapping[str, AttributeColumn] | None = None
  • time_column: str | None = None
  • details: Mapping[str, str] | None = None

FeatureDetails

  • feature_id: int
  • found: bool
  • attributes: dict

LayerRegistry

Bind versioned point layers to catalog identities and host-supplied grants.

  • __init__(self, connection: DuckDBPyConnection, layers: Mapping[LayerId, RegisteredLayer], authorize: Callable[[object, LayerId, str], bool])
  • fetch(self, principal: object, layer_id: LayerId, viewport: Viewport, *, zoom: int | None=None, where: FilterSpec | None=None, time: TimeRange | None=None) → tuple[str, list[MapPoint] | list[GridCell]]

    Fetch one authorized layer version, rejecting a replaced catalog.

  • details(self, principal: object, layer_id: LayerId, *, version: str, feature_ids: list[int]) → list[FeatureDetails]

    Fetch only the declared detail fields for an authorized immutable version.

TileId

  • zoom: int
  • x: int
  • y: int

VectorTileLayer

Encode a host-registered EPSG:3857 relation as Mapbox Vector Tiles.

  • __init__(self, connection: DuckDBPyConnection, relation: str, layer_name: str, *, attributes: Mapping[str, str] | None=None, catalog: str | None=None)
  • fetch(self, tile: TileId, *, buffer: int=256) → bytes

    Return an empty tile as zero bytes. Buffer size is in tile coordinates.

TileOccupancy

Use point occupancy for a committed Web Mercator snapshot to skip empty tiles.

  • __init__(self, layer, version, levels)
  • build(cls, layer: VectorTileLayer, version: str, *, max_zoom: int=10, max_cells: int=500000) → 'TileOccupancy'
  • might_have_feature(self, version: str, tile: TileId, *, buffer: int=256) → bool
  • fetch(self, version: str, tile: TileId, *, buffer: int=256) → bytes

TileScope

Host-supplied cache identity for a tenant's authorized tile projection.

  • tenant: str
  • layer: str
  • visibility: str
  • version: str | None
  • projection: str

TileResponse

  • body: bytes | None
  • etag: str | None
  • not_modified: bool

TileCache

An LRU of immutable tiles with byte and entry limits.

  • __init__(self, *, max_entries: int, max_bytes: int)
  • fetch(self, scope: TileScope, tile: TileId, generate: Callable[[], bytes], *, authorize: Callable[[TileScope], bool], if_none_match: str | None=None) → TileResponse

    Resolve a tile under current grants and omit its body on an exact ETag match.

TileSubscription

One authorized subscriber to shared generation work.

  • __init__(self, future, release, authorized)
  • result(self, timeout=None) → bytes
  • cancel(self) → bool

SharedTileWork

Coalesce in-flight tile generation while tracking subscriber cancellation.

  • __init__(self, *, workers: int)
  • close(self)
  • subscribe(self, scope: TileScope, tile: TileId, generate: Callable[[Event], bytes], *, authorize: Callable[[TileScope], bool]) → TileSubscription