duckh3 0.3.0
- New introductory vignette, “Getting started” (
vignette("duckh3")). - Updated the
duckdbdependency to v2.0.0 See https://r.duckdb.org/news/index.html#duckdb-200.
BREAKING CHANGES
-
resolutionno longer defaults to8: it is now required inddbh3_lonlat_to_h3(),ddbh3_lonlat_to_spatial(),ddbh3_get_parent(),ddbh3_get_children(),ddbh3_get_center_child(),ddbh3_get_n_children()andddbh3_get_child_pos(), as it already was inddbh3_points_to_*(),ddbh3_polygons_to_*()andddbh3_lines_to_*(). A fixed default is rarely right for relative operations (e.g. the parent at resolution 8 of a resolution 6 cell isNA) (#40). - Consistent argument order:
containment(andbuffer_scale) now come right afterresolutioninddbh3_polygons_to_spatial()andddbh3_lines_to_spatial(), as inddbh3_polygons_to_h3()andddbh3_lines_to_h3(); andnestedcomes right afternew_columnin every function. Only calls that pass these arguments by position are affected (#40). - In vectorized mode,
ddbh3_h3_to_spatial()andddbh3_h3_to_points()now followmode: they return aduckspatial_df(mode = "duckspatial", the default) or ansf(mode = "sf"), both with the indexes and their geometry in EPSG:4326. Before, they returned awk_wkbvector without CRS (#37).
BUG FIXES
-
ddbh3_default_conn()no longer reuses a default connection created byduckspatialwithbigint = "numeric", which silently rounded UBIGINT H3 indexes. It now warns and replaces it with aninteger64connection. - Column-name arguments (
new_column,h3,h3vertex,lon,lat) and the geometry column name are now quoted as SQL identifiers, so names with spaces or quotes work and SQL expressions passed as column names are no longer executed. - When the input already has a column named like
new_column, the result now replaces that column. Before, the result was added as<new_column>_1and the original column kept its old values. - Writing the result to the input table itself (
nameequal to the source table andoverwrite = TRUE) no longer deletes the source table: the result is now built in a staging table and swapped in place. -
ddbh3_create_conn()now registers theddbh3_*macros, so they work insidedplyr::mutate()on user-created connections. -
ddbh3_default_conn(create = FALSE)no longer errors when no default connection exists. -
ddbh3_vertex_to_lon(),ddbh3_vertex_to_lat()andddbh3_is_vertex()no longer reject valid H3 vertexes in vectorized mode, andddbh3_is_vertex()returnsFALSEfor invalid input instead of erroring. -
ddbh3_create_conn()andddbh3_default_conn()setgeometry_always_xy = true, which DuckDB >= 2.0 requires before spheroid functions such asduckspatial::ddbs_area()can run on H3 geometries. This keeps the pre-2.0 axis convention that duckspatial’s measure functions are written for. -
ddbh3_child_pos_to_cell()no longer errors when the child position column is stored as a double (e.g.data.frame(h3child_pos = 0)). - Writing to a schema-qualified table with
overwrite = TRUE(e.g.name = "my_schema.my_table") no longer moves the table to themainschema (#25). - Functions no longer fail when they are called before
ddbh3_default_conn(): the default connection is now set up with the h3 extension (andbigint = "integer64") when needed, in vectorized and table modes (#26). -
ddbh3_get_base_cell_number(),ddbh3_grid_disk(),ddbh3_grid_disk_distances(),ddbh3_grid_ring(),ddbh3_grid_path_cells()andddbh3_grid_distance()now quote column names, so names with spaces or quotes work (#27). -
ddbh3_grid_disk_distances()now returns all the cells within distancek(it only returned the cells at distance 1), also in vectorized mode (#28). -
ddbh3_h3_to_spatial()andddbh3_h3_to_points()now accept abit64::integer64vector of cells in vectorized mode (#31). - The hexagons created by
ddbh3_h3_to_spatial(),ddbh3_lonlat_to_spatial()andddbh3_h3_to_points()are always stored with the EPSG:4326 CRS. Before, a spatial input in another CRS gave its CRS to the new geometries when writing a table withname(#31). -
ddbh3_vertex_to_spatial()on a nested vertex column now builds theMULTIPOINTgeometries in a single query. It now works withname, and with spatial inputs whatever their geometry column is called (#32). -
ddbh3_edge_to_spatial()andddbh3_vertex_to_spatial()now detect nested columns in table names and lazy tables (#32). -
ddbh3_grid_path_cells(),ddbh3_grid_distance()andddbh3_child_pos_to_cell()give an informative error whenxis a vector (they need a table with two columns) instead of an obscure SQL error (#30). - Better argument validation:
kmust be between 0 and 1500,buffer_scalemust be a positive number,h3_formatmust be a single string, and inputs without a CRS give the “CRS must be EPSG:4326” error (#33). -
ddbh3_compact()errors whennew_columnis one of thebycolumns (#33). -
ddbh3_default_conn()now appliesthreadsandmemory_limit_gbto an existing default connection, instead of silently ignoring them (#33). - Vectorized mode no longer warns about invalid elements when the input has
NAs (#33). -
ddbh3_create_conn()warns whenbigintis not"integer64", since H3 indexes stored asUBIGINTare then rounded (#33). -
modeis now validated: values other than"duckspatial"or"sf"give an error, instead of silently returning aduckspatial_df(#36, reported upstream as Cidree/duckspatial#197). - In vectorized mode, results that are
NAfor valid cells (e.g.ddbh3_get_parent()to a finer resolution) now warn that the other arguments may be incompatible with the input, instead of saying thatxis invalid. Empty list results (e.g.ddbh3_get_children()to a coarser resolution) now warn too (#37). -
ddbh3_compact()andddbh3_uncompact()return a zero-length vector for a zero-length input (they returnedNULL), and validate and compute in a single query in vectorized mode (#37). -
ddbh3_default_conn(bigint = ...)warns thatbigintis ignored, instead of failing withformal argument "bigint" matched by multiple actual arguments(#38). - Vectorized mode accepts factors and all-
NAlogical vectors (e.g.NA), and other logical vectors give an informative error. Before, factors were taken as table names (#38). -
ddbh3_h3_to_vertexes()now works insidedplyr::mutate()(#39).
DOCUMENTATION
- The examples no longer say that
ddbh3_default_conn()is mandatory: it is created when needed since #26 (#42). - Documented that
nestedis ignored in vectorized mode, thatddbh3_polygons_to_spatial()andddbh3_lines_to_spatial()drop features without cells, thatresolutionmust be compatible with the input cells in hierarchy functions, and that replacing abigint = "numeric"default connection leaves the old one open (#42).
ENHANCEMENTS
Remove arrow lambda syntax for compatibility with DuckDB v2.0 (#6).
The
@returnsdocumentation now states that spatial outputs are returned assfwithmode = "sf", that*_to_spatial()functions andddbh3_h3_to_points()always return spatial output, and thatmodeis ignored for non-spatial results (#10).Internal helpers now reuse those of
duckspatial(e.g. identifier quoting withsql_ident(), table names withsql_table(), and extension checks), so both packages handle names and connections the same way. Two related problems were reported upstream: Cidree/duckspatial#195 (schema-qualified table names as input) and Cidree/duckspatial#196 (length-2name).Vectorized mode is up to ~40x faster: input validation and evaluation now run in a single query, and the default connection is no longer re-initialised on every call. The h3 extension check is cached for the default connection.
Faster polygon/line to H3 conversion: polyfill reads WKB instead of WKT, the geometry type is validated on the already-prepared input instead of preparing it twice, and the cell list is no longer de-duplicated twice.
Internal clean-up: the input preparation shared by every function is now a single helper (
ddbh3_points_to_*()use the templates too), and SQL string literals are always quoted with theduckspatialhelper (#43).
NEW FEATURES
All functions gain a
modeargument that can be set to “sf” or “duckspatial” to return the output in that format. Alternatively, the user can useduckspatial::ddbs_options()to set the mode globally.H3 directed edges:
ddbh3_h3_to_edge(),ddbh3_h3_to_edges(),ddbh3_edge_to_origin(),ddbh3_edge_to_destination(),ddbh3_edge_to_h3(),ddbh3_reverse_edge(),ddbh3_get_edge_length()andddbh3_edge_to_spatial()create directed edges from H3 cells and convert them to cells, lengths and lines. They also work insidedplyr::mutate()on lazy tables (exceptddbh3_edge_to_spatial()).ddbh3_compact()andddbh3_uncompact(): compact a set of H3 cells into the smallest set of cells covering the same area (optionally per group withby), and uncompact cells back to a single resolution.ddbh3_compact()also works insidedplyr::summarise(), andddbh3_uncompact()insidedplyr::mutate()on list columns.ddbh3_h3_to_local_ij()andddbh3_local_ij_to_h3()convert H3 cells to local IJ coordinates relative to an origin cell, and back. They also work insidedplyr::mutate()on lazy tables.ddbh3_is_index()checks if an index is any valid H3 index (cell, directed edge or vertex), andddbh3_digits_to_h3()builds H3 cells from a base cell and a list of digits. They also work insidedplyr::mutate()on lazy tables.H3 metrics:
ddbh3_get_area()gets the area of H3 cells,ddbh3_great_circle_distance()gets the great circle distance between two points, andddbh3_get_hexagon_area_avg()andddbh3_get_hexagon_edge_length_avg()get the average hexagon area and edge length at one or more resolutions. They also work insidedplyr::mutate()on lazy tables.ddbh3_is_edge(): check if an index is a valid H3 directed edge.ddbh3_is_neighbor(): check if two H3 cells are neighbors.ddbh3_grid_path_cells(): find a grid path connecting two H3 cells.ddbh3_grid_distance(): get the grid distance between two H3 cells.ddbh3_grid_disk(),ddbh3_grid_disk_distances(),ddbh3_grid_ring(): get H3 grid neighborhoods (disks, rings, and distances).ddbh3_grid_disk_distances()returns the grid distance of each cell in a second column (new_column = c("h3neighbors", "h3distance")), and all three use the pentagon-safe algorithm by default (safe = TRUE).ddbh3_max_grid_disk_size(): get the maximum grid disk size for a given distance k.ddbh3_child_pos_to_cell(): get an H3 child cell from a parent and child position.ddbh3_get_base_cell_number(): get the base cell number of an H3 cell.The neighborhood functions,
ddbh3_get_base_cell_number()andddbh3_child_pos_to_cell()also work insidedplyr::mutate()on lazy tables (#30).Documentation fixes: roxygen templates, aliases, examples and DESCRIPTION (#34).
duckh3 0.2.0
CRAN release: 2026-10-11
ENHANCEMENTS
Functions in vectorized mode automatically parse to UBIGINT when the input is a numeric vector.
Error message on wrong CRS is now displayed correctly (#3).
NEW FEATURES
- New functions to convert polygon and linestring geometries to H3 cells (#2):
-
ddbh3_polygons_to_h3()/ddbh3_lines_to_h3()add a list column with the H3 cells intersecting each feature (string orUBIGINT). -
ddbh3_polygons_to_spatial()/ddbh3_lines_to_spatial()return one row per intersecting cell, with geometry replaced by the cell hexagon boundary. - Polygons use DuckDB’s experimental polygon polyfill (
overlapcontainment by default); lines are polyfilled via a buffer-then-exact-trim strategy since they have no native polyfill (buffer_scaleargument).
-
