MyNixOS website logo
Description

H3 Extension of 'DuckDB'.

Fast & memory-efficient functions to analyze and manipulate large data sets. It leverages the fast analytical capabilities of 'DuckDB' and its spatial extension (see <https://duckdb.org/community_extensions/extensions/h3>) while maintaining compatibility with R’s spatial data ecosystem to work with spatial vector data.

duckh3 duckh3 website

CRANstatus Lifecycle:experimental Codecov testcoverage License: GPLv3 Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. check

{duckh3} provides fast, memory-efficient functions for analysing and manipulating large spatial and non-spatial datasets using the H3 hierarchical indexing system in R. It bridges DuckDB’s H3 extension with R’s data and spatial ecosystems — in particular {duckspatial}, {dplyr}, and {sf} — so you can leverage DuckDB’s analytical power without leaving your familiar R workflow.

How it works

{duckh3} was built around the same API as the duckspatial R package, and it operates on regular R data frames, tibbles, dbplyr lazy tables, and duckspatial_df objects. Unlike purely spatial workflows, H3 operations do not require your data to be spatial. Any table with longitude/latitude columns, or an existing H3 index column, is a valid starting point.

When a DuckDB connection is used, all H3 operations run inside that connection with the H3 extension enabled, letting DuckDB apply its own query optimisations before any data reaches R. Results are returned lazily and only materialised when you explicitly collect them.

In addition, {duckh3} registers a set of DuckDB macros on the default connection at load time, making H3 functions available directly inside dplyr::mutate() on lazy tables — no wrapper function needed. Note that they only work with lazy tables, not with regular data frames.

Naming conventions

All functions follow the ddbh3_*() prefix (DuckDB H3), structured around the expected input data, and what they will be converted to:

  • ddbh3_lonlat_to_*() — from longitude/latitude coordinates to H3 representations
  • ddbh3_points_to_*() — from spatial point geometries to H3 representations
  • ddbh3_h3_to_*() — convert H3 cells to other representations
  • ddbh3_vertex_to_*() — convert H3 vertexes to other representations

With the following available transformations:

Function familyOutput
*_to_h3()H3 index as string or UBIGINT
*_to_spatial()H3 cell as spatial hexagon polygon
*_to_lon()Longitude of H3 cell centroid
*_to_lat()Latitude of H3 cell centroid

And there are also a set of function to retrieve or check properties of the data:

  • ddbh3_get_*() — retrieve H3 cell properties (resolution, parent, children, vertices…)
  • ddbh3_is_*() — check properties of H3 indexes (valid, pentagon, Class III…)

Installation

Install the stable release from CRAN:

pak::pak("duckh3")

Install the latest GitHub version (more features, fewer accumulated bugs):

# install.packages("pak")
pak::pak("Cidree/duckh3")

Install the development version (may be unstable):

pak::pak("Cidree/duckh3@dev")

Contributing

Bug reports, feature requests, and pull requests are very welcome!

Metadata

Version

0.1.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows