Skip to contents

Setup the default connection with h3 and spatial extensions installed and loaded. It will be used internally by the package functions if no other connection is provided

Usage

ddbh3_default_conn(create = TRUE, upgrade_h3 = FALSE, ...)

Arguments

create

Logical. If TRUE and no connection exists, create one. Default is TRUE.

upgrade_h3

Logical. If TRUE, will attempt to upgrade the h3 extension

...

Additional parameters to pass to duckspatial::ddbs_create_conn() (e.g. threads). If a default connection already exists, threads and memory_limit_gb are applied to it, and the rest are ignored with a warning. bigint is always ignored (with a warning).

Value

Invisibly, the default duckdb_connection

Details

The default connection is shared with duckspatial (it is stored in options("duckspatial_conn")). It always uses bigint = "integer64", so H3 indexes stored as UBIGINT are not rounded: if duckspatial already created a default connection with bigint = "numeric", it is replaced with a warning. The old connection is not closed, so lazy tables that use it keep working.

Examples

## Get or create the default connection
conn <- ddbh3_default_conn(threads = 1)

## Calling it again returns the same connection
identical(conn, ddbh3_default_conn())
#> [1] TRUE