Skip to content
Merged

Dev #140

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

**duckspatial** is an R package that bridges DuckDB's spatial extension with R's spatial ecosystem (primarily `sf`). It exposes 100+ functions under the `ddbs_*` naming convention and introduces a `duckspatial_df` class — a lazy spatial data frame backed by temporary DuckDB tables/views with `dbplyr`.

Functions of the DuckDB's spatial extension can be consulted [here](https://duckdb.org/docs/current/core_extensions/spatial/functions).

Key design principle: operations stay in DuckDB until the user explicitly collects results, enabling out-of-memory spatial workflows.

## Common Commands
Expand Down Expand Up @@ -97,6 +95,8 @@ When implementing a new exported function, complete **all four steps** before co

### 1. Implementation and documentation

Find the official function's documentation [here](https://duckdb.org/docs/current/core_extensions/spatial/functions).

Write the function in the R file that best matches its category (see Key File Map above). Add full `roxygen2` documentation using the template tags already present in the file (`@template x`, `@template conn_null`, etc.) — reuse them rather than duplicating the parameter prose. Run `devtools::document()` afterwards.

### 2. Unit tests
Expand All @@ -120,3 +120,19 @@ Add one bullet under `## NEW FEATURES` of the **topmost** (development) version
### 4. _pkgdown.yml

Read `_pkgdown.yml` to find the most appropriate `reference:` section and add the function name to its `contents:` list. If no existing section fits, create a new one following the same `title` / `desc` / `contents` structure.

### 5. Git commit

Use a conventional commit with this exact format:

```
feat: New function: ddbs_fun (#issue_number).
```

For a group of related functions introduced together, use the group name instead of individual names:

```
feat: New functions: ddbs_group_name (#issue_number).
```

(e.g. `ddbs_coord_bounds` for `ddbs_xmin`, `ddbs_xmax`, etc.)
6 changes: 3 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macos-latest, r: 'release'}
- {os: ubuntu-22.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-22.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-24.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
- {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
- {os: ubuntu-24.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}

env:
RSPM: ${{ matrix.config.rspm }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_as_cran.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
config:
- {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}

env:
RSPM: ${{ matrix.config.rspm }}
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: duckspatial
Title: R Interface to 'DuckDB' Database with Spatial Extension
Version: 1.1.1
Version: 1.1.1.9000
Authors@R: c(
person(
"Adrián", "Cidre González",
Expand Down Expand Up @@ -70,4 +70,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
Config/roxygen2/version: 8.0.0
14 changes: 14 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export(ddbs_as_hexwkb)
export(ddbs_as_points)
export(ddbs_as_text)
export(ddbs_as_wkb)
export(ddbs_azimuth)
export(ddbs_bbox)
export(ddbs_boundary)
export(ddbs_buffer)
Expand All @@ -70,6 +71,7 @@ export(ddbs_create_schema)
export(ddbs_crop)
export(ddbs_crs)
export(ddbs_difference)
export(ddbs_dimension)
export(ddbs_disjoint)
export(ddbs_distance)
export(ddbs_drivers)
Expand Down Expand Up @@ -109,6 +111,7 @@ export(ddbs_join)
export(ddbs_length)
export(ddbs_line_endpoint)
export(ddbs_line_interpolate)
export(ddbs_line_locate_point)
export(ddbs_line_merge)
export(ddbs_line_startpoint)
export(ddbs_line_substring)
Expand All @@ -123,11 +126,14 @@ export(ddbs_make_polygon)
export(ddbs_make_valid)
export(ddbs_maximum_inscribed_circle)
export(ddbs_minimum_rotated_rectangle)
export(ddbs_mmax)
export(ddbs_mmin)
export(ddbs_multi)
export(ddbs_open_dataset)
export(ddbs_options)
export(ddbs_overlaps)
export(ddbs_perimeter)
export(ddbs_point)
export(ddbs_polygonize)
export(ddbs_predicate)
export(ddbs_quadkey)
Expand All @@ -144,6 +150,7 @@ export(ddbs_set_crs)
export(ddbs_set_resources)
export(ddbs_shear)
export(ddbs_shift)
export(ddbs_shortest_line)
export(ddbs_simplify)
export(ddbs_sitrep)
export(ddbs_startpoint)
Expand All @@ -153,15 +160,22 @@ export(ddbs_touches)
export(ddbs_transform)
export(ddbs_union)
export(ddbs_union_agg)
export(ddbs_vertices)
export(ddbs_voronoi)
export(ddbs_within)
export(ddbs_within_properly)
export(ddbs_write_dataset)
export(ddbs_write_table)
export(ddbs_write_vector)
export(ddbs_x)
export(ddbs_xmax)
export(ddbs_xmin)
export(ddbs_y)
export(ddbs_ymax)
export(ddbs_ymin)
export(ddbs_z)
export(ddbs_zmax)
export(ddbs_zmin)
export(is_duckspatial_df)
importFrom(dplyr,arrange)
importFrom(dplyr,collect)
Expand Down
22 changes: 22 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# duckspatial (development version)

## NEW FEATURES

* `ddbs_shortest_line()`: returns the LINESTRING connecting the closest points between each pair of geometries from `x` and `y`.

* `ddbs_azimuth()`: computes the clockwise azimuth (bearing from north) between two sets of POINT geometries. Returns a numeric matrix (`mode = "sf"`) or a lazy tbl with all pairs (default). Supports radians (default) and degrees via the `unit` argument.

* `ddbs_vertices()`: collects all vertices of a geometry into a MULTIPOINT.

* `ddbs_point()`: creates POINT geometries from numeric coordinate vectors. Supports 2D, 3D (Z), and 4D (Z + M) coordinates, extra attribute columns via `...`, and CRS assignment.

* `ddbs_xmax()`, `ddbs_xmin()`, `ddbs_ymax()`, `ddbs_ymin()`, `ddbs_zmax()`, `ddbs_zmin()`, `ddbs_mmax()`, `ddbs_mmin()`: return the maximum or minimum coordinate value for each geometry (`by_feature = TRUE`) or the global extreme across the dataset (`by_feature = FALSE`).

* `ddbs_dimension()`: returns the topological dimension of each geometry (0 = point, 1 = line, 2 = polygon, -1 = empty).

* `ddbs_line_locate_point()`: returns the fractional position (0–1) of the closest point on a linestring to a reference point. The `y` argument accepts an `sf` object, a `duckspatial_df`, or a character DuckDB table name (each must contain exactly 1 point feature).

## ENHANCEMENTS

* `ddbs_union_agg()`: gains a `mem` argument. Set `mem = TRUE` to use `ST_MemUnion_Agg()` instead of `ST_Union_Agg()` — slower but more memory efficient.

# duckspatial 1.1.1

## NEW FEATURES
Expand Down
11 changes: 8 additions & 3 deletions R/db_extension.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
#'
#' # install the spatial extension
#' ddbs_install(conn)
#'
#' # install the h3 community extension
#' ddbs_install(conn, extension = "h3")
#'
#' # disconnect from db
#' duckdb::dbDisconnect(conn)
#'
#' \dontrun{
#' # install the h3 community extension (requires network access)
#' conn <- duckdb::dbConnect(duckdb::duckdb())
#' ddbs_install(conn, extension = "h3")
#' duckdb::dbDisconnect(conn)
#' }
ddbs_install <- function(
conn,
upgrade = FALSE,
Expand Down Expand Up @@ -97,6 +101,7 @@ ddbs_install <- function(
cli::cli_abort(c(
"Failed to {if (upgrade) 'upgrade' else 'install'} the {extension} extension.",
"i" = "It could not be found in the core or community repositories.",
"i" = "It might not be available for this version of DuckDB",
"i" = "Check that the extension name is correct: {.url https://duckdb.org/docs/extensions/overview}"
))
}
Expand Down
Loading
Loading