Skip to content

New functions for v1.2.0 - #142

Merged
Cidree merged 27 commits into
mainfrom
new-feats
Jun 28, 2026
Merged

New functions for v1.2.0#142
Cidree merged 27 commits into
mainfrom
new-feats

Conversation

@Cidree

@Cidree Cidree commented Jun 26, 2026

Copy link
Copy Markdown
Owner

NEW FEATURES (#143)

  • ddbs_extension_info(): prints a glimpse() of a DuckDB extension's row from duckdb_extensions() (the spatial extension by default), showing its installed/loaded status, version, and install path.

  • ddbs_reduce_precision(): snaps geometry coordinates to a regular grid, reducing their precision.

  • ddbs_line_node(): nodes a set of line geometries, splitting them at every crossing and returning a fully noded MULTILINESTRING.

  • ddbs_intersection_agg(): computes the geometric intersection (common area) of a set of geometries, optionally grouped by one or more columns. The intersection counterpart to ddbs_union_agg().

  • ddbs_reverse(): returns each geometry with the order of its vertices reversed.

  • ddbs_normalize(): returns each geometry in its normalized (canonical) form.

  • ddbs_write_mbtiles(): generates a Mapbox Vector Tile pyramid from a spatial dataset and writes it to an MBTiles file, ready to serve or convert to PMTiles.

  • ddbs_as_mvt_geom(): transforms geometries into Mapbox Vector Tile (MVT) coordinate space, clipping them to a tile's bounding box and mapping the coordinates into the tile's integer pixel space.

  • ddbs_geom_from_text(), ddbs_geom_from_wkb(), ddbs_geom_from_hexwkb(), ddbs_geom_from_hexewkb(), ddbs_geom_from_geojson(): parse serialized geometries (WKT, WKB, HEXWKB, HEXEWKB, GeoJSON) into a spatial object. These are the inverses of the ddbs_as_*() serializers.

  • ddbs_get_ninterior_rings(): returns the number of interior rings (holes) in a POLYGON geometry.

ENHANCEMENTS

  • ddbs_install(): gains a repos argument to install an extension from a specific DuckDB repository (e.g. "core", "core_nightly", "community"). When NULL (default), the previous behaviour is kept (core, then community) (Allow ddbs_install to install extensions from any repository #144).

  • ddbs_as_geojson(): now includes all non-geometry columns as feature properties instead of serializing only the geometry. By default it returns a single GeoJSON FeatureCollection (matching geojsonsf::sf_geojson()); pass feature_collection = FALSE for a vector with one Feature per row (ddbs_as_geojson() should convert all the features #141).

BUG FIXES

Cidree and others added 27 commits June 24, 2026 14:53
Quarto's R subprocess during R CMD build does not inherit the temp
library path from R_LIBS, causing library(duckspatial) to fail on some
platforms (notably Windows r-hub). Each vignette's first hidden chunk
now explicitly adds R_LIBS entries to .libPaths(). Also corrects
actions/checkout@v6 (non-existent) to @v4 in check.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
r-hub Linux containers run as root without sudo or jq, which are
required by quarto-dev/quarto-actions/setup@v2. Install them first
via apt-get (no sudo needed since the container is already root).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
'data data sets' -> 'datasets', '&' -> 'and' to satisfy CRAN
incoming feasibility checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CRAN rejected 1.1.2 as it matches the existing published version.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The atlas platform uses a Fedora-based container without apt-get; fall
back to dnf/yum so the sudo and jq install step succeeds there.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wraps ST_NumInteriorRings to return the number of interior rings (holes)
in a POLYGON geometry. Documented alongside the other geometry-component
counters (ddbs_get_npoints, ddbs_get_ngeometries).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a symmetric family of deserializers that parse serialized geometries
into a spatial object, the inverse of the ddbs_as_*() serializers:

- ddbs_geom_from_text()    (ST_GeomFromText)
- ddbs_geom_from_wkb()     (ST_GeomFromWKB)
- ddbs_geom_from_hexwkb()  (ST_GeomFromHEXWKB)
- ddbs_geom_from_hexewkb() (ST_GeomFromHEXEWKB)
- ddbs_geom_from_geojson() (ST_GeomFromGeoJSON)

They take an R vector (or a list of raw WKB vectors) plus a crs and
return a duckspatial_df/sf, optionally writing a named table. Shared
logic lives in the new template_geom_from() helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The quarto-actions/setup action downloads the Quarto bundle with wget,
which is absent from the Fedora-based atlas container. Add it to the
dependency install step alongside sudo and jq.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a dedicated R/ddbs_mvt.R gathering all Mapbox Vector Tile support:

- ddbs_as_mvt_geom(): low-level ST_AsMVTGeom wrapper mapping geometries
  into tile pixel space (drops CRS via a new template_unary_ops drop_crs
  flag).
- ddbs_write_mbtiles(): generates a vector tile pyramid (ST_AsMVTGeom +
  ST_AsMVT over a computed XYZ tile grid) and writes it to an MBTiles
  SQLite file through DuckDB's sqlite extension. Non-geometry columns are
  carried as feature properties (cast to MVT-supported types). The result
  can be served or converted to PMTiles for use with mapgl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…141).

Previously the function serialized only the geometry column via
ST_AsGeoJSON, dropping all attributes. It now builds a complete GeoJSON
Feature per row, placing non-geometry columns in the properties member
(empty object when there are none).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Building on the all-columns fix, ddbs_as_geojson() now defaults to a
single GeoJSON FeatureCollection string (class "geojson"/"json"),
structurally matching geojsonsf::sf_geojson() — the canonical form for
writing .geojson files and feeding web mapping libraries. Pass
feature_collection = FALSE for the previous one-Feature-per-row vector.
Empty inputs yield a valid empty FeatureCollection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The previous json_object/json_group_array approach round-tripped every
geometry through the JSON type, which was slow and exploded memory on
large data (OOM at ~23 GiB for 1e7 points). Build the Feature strings
and the FeatureCollection with plain SQL string concatenation and
string_agg instead: ~2x faster than the old code, faster than
geojsonsf::sf_geojson(), and a fraction of the memory.

Also bump the development version and drop the obsolete ddbs_as_geojson()
macro test (the macro is per-row and no longer matches the function's
FeatureCollection output).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…agg, ddbs_line_node, ddbs_reduce_precision (#143).

Add five wrappers for DuckDB spatial functions, each also registered as a
macro for use inside dplyr verbs:

- ddbs_reverse()           -> ST_Reverse
- ddbs_normalize()         -> ST_Normalize
- ddbs_intersection_agg()  -> ST_Intersection_Agg (optional `by` grouping)
- ddbs_line_node()         -> ST_Node
- ddbs_reduce_precision()  -> ST_ReducePrecision

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…AUDE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Glimpse a DuckDB extension's row from duckdb_extensions() (the spatial
extension by default), showing installed/loaded status, version, and
install path. Defaults conn = NULL to the default connection, matching
the rest of the package.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Cidree
Cidree merged commit ee8df90 into main Jun 28, 2026
8 checks passed
@Cidree
Cidree deleted the new-feats branch June 28, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant