Changes in version 1.1.2 Significant changes - writeGeoParquet() and writeSpatialPointsParquet() refuse columns whose names are the same up to case, as Gene and gene are, and say which. DuckDB, which reads these files, binds a column name without regard to the case of the letters A to Z, so a query for gene on a file that holds both returns the values of Gene without a message. A file was written with both before. Rename the columns before writing. The check is checkParquetColumnNames() of DuckDBDataFrame, which also refuses a name that is NA or empty. Bug fixes - writeSpatialPointsParquet() keeps the names of the columns of df as they are. It converted df with as.data.frame(), which makes a name that is not a valid R name, as n cells for a matrix or a list, into one that is. Changes in version 1.1.1 Significant changes - st_buffer() of a DuckDBTable, DuckDBDataFrame or DuckDBColumn now draws a quarter circle with 30 segments, the default of sf::st_buffer(), where it used the default of DuckDB, 8. A buffered point has 121 vertices, as it does in sf, and not 33. The shape is the same circle, drawn more finely, so the geometries are larger. Give nQuadSegs = 8 for the old result. New features - st_buffer() takes the other arguments of sf::st_buffer(): nQuadSegs, endCapStyle ("ROUND", "FLAT" or "SQUARE"), joinStyle ("ROUND", "MITRE" or "BEVEL") and mitreLimit. They were not accepted, and were ignored without a message, so endCapStyle = "SQUARE", which makes the square spots of a Visium HD array, gave a round buffer. DuckDB's ST_Buffer() takes these options together and spells them CAP_SQUARE, JOIN_MITRE and so on, and the styles are mapped from the names of sf, in any case. The results equal those of sf for points, lines and polygons. singleSide = TRUE is an error, since DuckDB cannot buffer on one side only. An argument that st_buffer() does not know is an error, and so is a dist that is not a single number. - st_union(x) of a DuckDBTable or DuckDBDataFrame with no y returns the union of all its geometries as an sfc of length one, as sf::st_union() does for an sf data frame. It was an error that asked for y, which made it impossible to take the union of the cells of a table before st_concave_hull(), for the boundary of a tissue. Bug fixes - st_union(x) of a DuckDBColumn with no y dropped the coordinate reference system: the union of geometries in EPSG:3857 had none. It read the union as WKT text. It is now kept as a geometry, so the result has the CRS of the column. The table and the column methods share the one code path. Testing - New tests compare st_buffer() with sf::st_buffer() for points, lines and polygons, with every end cap and join style and two segment counts, the square cap of a Visium HD spot through a table and a column, the default of 30 segments, and the checks on the arguments. Others compare st_union() with no y of a table and of a column, and of a subset of the rows, with sf, including the CRS, and the union followed by st_concave_hull(). They fail on the previous code. Changes in version 0.99.23 New features - convertToGeoParquet() writes a spatial file that GDAL can read, such as GeoJSON, GeoPackage or Shapefile, as a GeoParquet file. DuckDB streams the conversion through ST_Read(), so the data does not pass through R. layer picks a layer of a source that has several, and geom names the geometry column, which GDAL calls geom. The index of the feature in the file, OGC_FID, is dropped unless keep_fid = TRUE. The file is written beside its target and renamed, so a failure does not leave a partial file. - readSpatialFile() converts a file in the same way and returns the result of readGeoParquet(), a lazy DuckDBDataFrame. The converted file is in the tempdir() of the session unless to gives a path. keycol is passed on, and keycol = "OGC_FID" keeps and uses the index of the feature in the file. - A GeoJSON or similar file is converted, and not read lazily, because DuckDB reads it with ST_Read(), which parses the whole file again for every query and cannot skip columns or rows. A query on the converted file does neither. - crs of convertToGeoParquet() and readSpatialFile() says what to do about the coordinate reference system. NULL, the default, keeps the CRS that GDAL reports; an EPSG code, a CRS string or an sf crs object assigns that CRS without reprojecting; NA records the CRS as unknown. An unknown CRS is written as an explicit null in the GeoParquet metadata, since a GeoParquet file without a CRS is read as OGC:CRS84. DuckDB does not write the metadata in that case, so the source is read once more to find the bounding box and the geometry types, and the types are left empty, which means unknown, when a geometry is not a plain 2D type. - GDAL gives a GeoJSON file that has no CRS the CRS EPSG:4326, since GeoJSON is defined in WGS84. Coordinates that are not longitude and latitude, such as the pixel coordinates of cell outlines, are then labelled wrongly, and crs = NA records them as unknown. The help page says so. Testing - A new test file, test-convertToGeoParquet.R, checks that a converted GeoJSON keeps its attributes, geometries and CRS, compared with the sf object that was written; that the CRS is kept, assigned or recorded as unknown, with the metadata that each case writes; the geometry types of an unknown CRS, with mixed types and with a Z geometry; the choice of a layer of a GeoPackage; the name of the geometry column and a clash with a column of the file; keep_fid; the checks on the arguments, an existing target, and a file that GDAL cannot read leaving no partial file; and readSpatialFile() with and without a key and a path. Changes in version 0.99.22 Significant changes - st_intersects_table() now returns pairs in the form that sf::st_intersects(x, y) gives: id_x is the row of x and id_y is the row of y, which is 1 because y is a single geometry. Before, id_x only counted the rows that matched and id_y held the rows of x, so a table of matches had the row of x in the column named for y. Code that read the rows of x from id_y has to read id_x. Bug fixes - st_join_table() and st_intersects_table() numbered the rows with row_number() over the scan of the file, so the ids were the positions of the rows in the file and not in the order of the table, which is the stored order of its keys. For a table with a named key whose file is not in key order, x[id_x, ] was a different row from the one that matched. The ids are now the positions in the order of x and of y, computed with DuckDBDataFrame::addRowPosition(). - st_intersects_table() failed with a binder error on a geometry column that is WKT text, which st_join_table() already cast. It casts it as well now. Internal changes - The column that the layer engines use inside their query for the flag that a row hit is named __hit__. It used to be .hit, and now follows the style of the columns that reach files and schemas, such as __name__ and __index__. Only the name changed. Testing - New tests compare the pairs of st_join_table() and the rows of st_intersects_table() with sf::st_intersects() for a keyed table whose file is not in key order, with a native geometry column and with a WKT text column. They fail on the previous code. - A test of the layer engines assumed that the stored order of a named character key is not its sorted order. Keys that are derived from the file are stored in sorted byte order, which is also the order that sort() gives under the C collation that R CMD check uses, so the test failed there and passed only in a locale such as en_US.UTF-8. It now gives the layer a key order of its own, which is neither the order of the file nor the sorted order, in any locale. Changes in version 0.99.21 Significant changes - st_join() on a DuckDBTable or DuckDBDataFrame now follows sf::st_join(). It is a left join by default, so a row of x that matches nothing is kept, where before it was dropped by an inner join that ignored left. Use left = FALSE for the old result. The result has all of x, then the attributes of y with suffix (default c(".x", ".y")) on any name the two share, then one geometry column. A named key of x or y is kept as a column. largest = TRUE is an error, since it is not supported. Bug fixes - layerSpatialOverlaps(), layerSubsetByBbox(), layerSubsetByGeometry() and layerSpatialMatch() gave wrong rows for a layer with a named key. They returned results in the order the database scanned the rows, but such a layer is read in the order of its stored keys, which is neither the order of the file nor the order the database sorts the keys in (for character keys it is not even sorted). For a file with id = c(3, 1, 2) and x = c(30, 1, 5), layerSubsetByBbox(0, 10, ...) returned the rows with x 5 and 30, not 1 and 5. The results are now put in stored-key order, for a keyed layer and for a keyed table in layerSpatialMatch(). A layer numbered by row is unchanged. Since subsetByBoundingBox() and subsetByPolygon() in BiocDuckDB use these functions, they were affected too. - layerSpatialMatch() treated every predicate except st_within as st_intersects, so join = st_contains or st_touches silently returned intersects. It now maps the predicate as st_join() does and stops for one it cannot express. - A geometry given to a predicate, distance or join as an sf object or sfg was sent to DuckDB as text with 7 significant digits, which moved a UTM-scale or micron-scale coordinate by metres. For a point at (123456.123456789, 4567890.987654321), st_distance() to the identical point returned 0.0265, st_intersects() returned FALSE, and st_join() matched nothing. Geometries are now sent with 17 significant digits, which round-trips any double. - st_join() returned the internal row_number columns of both tables and two geometry columns, and failed with a binder error for a table whose geometry column is not called geometry. st_join(), st_join_table(), st_intersects_table() and st_filter() now find the geometry column by its type, and fall back to geometry only when there is not exactly one. - st_union_agg(), st_collect_agg() and st_envelope_agg() stopped with an error for a DuckDBTable or DuckDBDataFrame, though they are documented to take one. They now use the table's geometry column. - A connection that returns geometry through wk, such as the one that duckspatial::ddbs_create_conn() opens, gives a wk_wkb vector, which st_as_sf() and st_as_sfc() could not convert. It is now converted. - writeGeoParquet() of a DuckDBTable or DuckDBDataFrame dropped the CRS: the table was collected as a plain data frame, and the CRS lives in the GEOMETRY type, not in the collected WKB. A layer in EPSG:3857 was written, and read back, with no CRS. The table is now collected as an sf data frame, which keeps it. - DuckDB 2.0 refuses ST_Transform and the spheroid functions until geometry_always_xy is set. It is now set once on the shared connection when the package loads, since coordinates here are always (x, y); DuckDB 2.1 makes this the default. Documentation - The design vignette said a spatial filter is evaluated during the Parquet scan. DuckDB prunes row groups for a spatial predicate only from the bounds a file records for a native Parquet geometry column. The GeoParquet 1.0 files that writeGeoParquet() writes hold plain WKB with no per-row-group bounds, so every row group is read, and st_filter() and row subsetting read the whole geometry column to find the matching rows. The vignette now says so, and points to layerBboxRange() over a file from writeSpatialPointsParquet() for points. - layerBboxRange() prunes row groups only for a layer with a named key. On a layer numbered by row the filter is applied after the numbering and is not pushed into the scan. The help page now says so. - The introductory vignette says that st_area(), st_length(), st_perimeter() and st_distance() are planar, in the units of the coordinates: for a layer in longitude and latitude they give square degrees or degrees, where sf gives meters. - st_coordinates() on a table is documented as points only: for lines and polygons DuckDB stops with an error, where sf returns every vertex. Changes in version 0.99.20 New features - st_bbox() and st_coordinates() now work on a DuckDBTable or DuckDBDataFrame, as they do on an sf data frame, where before only a DuckDBColumn was supported. They act on the table's only GEOMETRY column, or on the one named by the new geom argument, and like the other table methods they stop if there is more than one and geom is not given. st_coordinates() returns just the coordinate columns. Bug fixes - st_bbox() on a DuckDBColumn dropped the CRS: the bbox it returned had no crs attribute, so a geometry in EPSG:4326 gave a bbox whose CRS was NA, unlike sf. The CRS is now read in the same query and attached, so functions that use it, such as st_as_sfc() on the bbox, keep it. Changes in version 0.99.19 Bug fixes - writeGeoParquet() omitted the crs key from a column's geo metadata when st_crs(x) was NA. The GeoParquet spec treats a missing crs as OGC:CRS84 (WGS84 lon/lat) and spells "unknown" as an explicit "crs": null, so readGeoParquet() (and any other reader) labeled coordinates with no CRS, such as spatial omics images or tissue slides, as longitude/latitude, which then altered axes in plots and geometric operations. An unknown CRS, or one PROJJSON cannot represent, is now written as "crs": null and reads back as NA; the append = TRUE CRS check likewise distinguishes a missing key from an explicit null, so a known CRS can no longer be appended to a file whose CRS is unknown. Files written by earlier versions carry no crs key and still read as OGC:CRS84, which is indistinguishable from an intentional CRS84; rewrite them to correct it. Thanks to Lambda Moses for the report and reprex. Changes in version 0.99.18 Bug fixes - writeGeoParquet() never added the GeoParquet spec's required " Z" suffix (e.g. "Point Z") to a 3D geometry's type in the written file's geo metadata, so readers like GDAL/OGR had no way to know a column had a Z coordinate without scanning every geometry. .geometryTypeToGeoParquet() now classifies each geometry individually (by type and whether it carries a Z coordinate, via a new .sfcHasZ() helper) before deduplicating, so a column mixing 3D and 2D geometries of the same base type (e.g. after writeGeoParquet(..., append = TRUE)) correctly lists both "Point Z" and "Point". Thanks to @buyan-kh for the fix and tests (#2, fixing #1). Changes in version 0.99.17 Bug fixes - Geometry-transforming methods on a DuckDBTable/DuckDBDataFrame (st_buffer(), st_centroid(), st_simplify(), and ~20 others, plus the binary set operations st_difference()/st_intersection()/st_union()) dropped every non-geometry column. 0.99.16 fixed these to stop applying their SQL function to every column, but narrowing to just the geometry column (via the new st_geometry.DuckDBTable) meant the result kept only that one column -- unlike plain sf, where e.g. st_buffer(an_sf_object, dist) returns the full object with every other column retained and just the geometry replaced (confirmed directly against sf's own source: every one of these methods' .sf dispatch is literally st_set_geometry(x, FUN(st_geometry(x), ...)) or the exact in-place equivalent). Added .sql_call_geom_replace(), which rewrites just the one GEOMETRY-typed column's own SQL expression in place -- leaving every other column, and row count, untouched -- and switched these methods (and nothing else: accessors, measures, and predicates correctly still return a bare, narrowed result, matching sf's own convention there too) to use it. Changes in version 0.99.16 Bug fixes - Every sf-compatible predicate/measure/transform method on a DuckDBTable/DuckDBDataFrame (st_intersects(), st_buffer(), st_area(), and ~50 others) applied its SQL function to every column of x, not just the geometry one. Calling e.g. st_intersects(a_duckdb_dataframe, y) on a layer with ordinary, non-geometry columns alongside "geometry" (the routine case for any DuckDBDataFrame used as an sf-like layer) failed with a confusing DuckDB binder error, e.g. No function matches the given name and argument types 'ST_Intersects(INTEGER, GEOMETRY)', because sql_call() built the SQL expression against every datacol. Reported externally against DuckDBSpatial::st_intersects(), but the same sql_call(x, ...) pattern affected the whole predicate/measure/transform family. Added st_geometry.DuckDBTable, a new exported method that narrows obj to its one GEOMETRY-typed column (detected by type, not by a name convention, so it makes no assumption about what the column is called) and errors clearly if obj does not have exactly one such column. Every affected method now narrows through it before building its SQL expression; DuckDBColumn's own delegation to these methods (its internal one-column table keeps the original column's name, not always literally "geometry") is unaffected, since detection no longer depends on a name at all. Changes in version 0.99.15 Bug fixes - Fixed a Bioconductor nebbiolo2 build-report WARNING: a stray @aliases st_crs.DuckDBColumn roxygen tag on DuckDBTable-spatial.R's st_crs.DuckDBTable documentation block duplicated the alias already correctly declared on DuckDBColumn-spatial.R's own st_crs.DuckDBColumn method, flagged as "Rd files with duplicated alias". Removed the stray tag. Changes in version 0.99.14 Bug fixes - layerSpatialMatch()/layerSpatialOverlaps() (geometry-column path) and st_join()/st_join_table() on a DuckDBTable/DuckDBDataFrame all assumed an existing geometry column was already DuckDB-native GEOMETRY, with no check or cast. .as_duckdb_table() already detects and casts a WKT-text geometry column, but only when uploading a fresh in-memory object for the first time; it's a no-op for anything that's already a DuckDBTable/DuckDBDataFrame, which is exactly the case these four functions hit. A DuckDBDataFrame/DuckDBTable built with a plain WKT-text geometry column (e.g. from a CSV, or any non-GeoParquet source) failed with a raw DuckDB binder error ("No function matches the given name and argument types 'ST_Intersects(GEOMETRY, VARCHAR)'") instead of working. All four now probe the column's actual type first (a cheap typeof(...) ... LIMIT 1 schema query, negligible next to the join itself) and wrap it in ST_GeomFromText() only when it isn't already GEOMETRY-typed, so an already-native column incurs no double-cast. Changes in version 0.99.13 Significant changes - st_as_sfc() for DuckDBTable/DuckDBDataFrame/DuckDBColumn now materializes into an in-memory sfc, instead of staying lazy (building ST_GeomFromText/ST_GeomFromWKB/ST_GeomFromGeoJSON SQL and returning another lazy DuckDBTable). This is a deliberate breaking change (the package is still pre-1.0/devel): in plain sf, st_as_sfc() and st_as_sf() are both always materializing, with no lazy variant at all; DuckDBSpatial had reinterpreted st_as_sfc()'s laziness while adding st_as_sf() (below) as materializing from the start, so the two sibling generics disagreed on the one axis they otherwise never differ on. That mismatch is the direct, confirmed root cause of two separate pieces of user confusion in a row (st_as_sfc() not materializing, then st_collect() combining every row instead): nothing in the package internally relied on st_as_sfc()'s laziness either (every real call site collects first, then calls plain sf::st_as_sfc() on the in-memory result). The rule is now simple and matches upstream sf exactly: every st_as_* generic in this package returns a real in-memory object, no exceptions, honoring the same contract plain sf does: an explicit, non-NA crs= overrides whatever CRS is already embedded (rather than being silently ignored on an already-GEOMETRY-typed column, as an earlier draft of this change did), ... reaches sf::st_as_sfc()'s own parsers, and a missing/NULL cell (SQL NULL, GeoParquet explicitly permits these) becomes an empty geometry instead of erroring, for WKB, WKT, and GeoJSON alike. A column already GEOMETRY-typed is collected and tagged with its own st_crs(), without needlessly collecting and parsing any other GEOMETRY-typed column in the same table; a WKT/GeoJSON/WKB column not yet GEOMETRY-typed is collected as-is and handed to plain sf::st_as_sfc()'s own parsers, rather than building a SQL cast just to immediately materialize the result anyway. The still-lazy, SQL-side parse (for chaining further lazy spatial ops at out-of-core scale without ever collecting) remains available, just honestly named: sql_call(x, "ST_GeomFromText") (or "ST_GeomFromWKB"/ "ST_GeomFromGeoJSON"). New features - st_as_sf(x, ..., geom = "geometry"): materializes a DuckDBTable/ DuckDBDataFrame into an in-memory sf object, one feature per row. Reported by a user who expected st_as_sfc() to do this (at the time, it stayed lazy; see "Significant changes" above, where that's now fixed too), then tried st_collect() instead and found it combined all rows into a single MULTIPOINT. That's actually correct for st_collect(): it wraps DuckDB's own ST_Collect SQL aggregate, a different operation entirely, just one whose name collides with the natural "collect a lazy object into memory" expectation. Neither function materializes; nothing in the package did. The fix: the duckdb R driver already returns a native GEOMETRY column as a list of raw WKB on collection (verified empirically, no ST_AsWKB cast needed first), so st_as_sf() collects x directly, parses every GEOMETRY-typed column (not just geom, so a second geometry column doesn't survive as inert raw bytes) via sf::st_as_sfc(), substitutes the real empty-geometry WKB encoding for any SQL-NULL cell (st_as_sfc() otherwise errors on a bare NULL list element), and tags each with its own CRS. - st_crs(x, geom = "geometry") for DuckDBTable/DuckDBDataFrame, and st_crs(x) for DuckDBColumn: reads a lazy geometry column's CRS via DuckDB's own ST_CRS SQL function, without collecting. Added because st_as_sf() needs it, and because DuckDBSpatial had no way at all to query a lazy object's CRS before this. Changes in version 0.99.12 New features - writeGeoParquet(x, path, ..., append = TRUE): requested by a user who wanted to add rows to an existing GeoParquet file incrementally rather than rewriting it each time. Appends \code{x} as new row groups via nanoparquet::append_parquet(), then updates the file's geo metadata in place: geometry_types is the union of the existing and new types, bbox is extended to cover both (omitted if either extent is unknown, rather than reporting a bbox that silently excludes rows), and the CRS is left as-is, but checked: x must have a matching CRS, or the append errors rather than embedding mismatched coordinates under one CRS label. append = TRUE requires path to already exist with GeoParquet metadata (write it first with append = FALSE); appending to a multi-part/hive-partitioned layout isn't supported. Requires the blob package (now in Suggests): append_parquet() reads the existing file's WKB column back as a blob::blob() vector internally to validate the combined schema, so the new data's geometry column has to match that representation (an AsIs list of raw vectors, fine for a fresh write_parquet() call, doesn't vctrs-cast to blob and errors). Bug fixes - .buildGeoParquetMetadata()'s jsonlite::toJSON(meta, auto_unbox = TRUE) call used jsonlite's default digits = 4, silently truncating numeric precision anywhere in the embedded metadata, including the CRS's own ellipsoid parameters (e.g. WGS84's inverse_flattening 298.257223563 truncated to 298.2572) every time writeGeoParquet() wrote a CRS. Found while adding the append = TRUE CRS-matching check above: comparing the file's recorded CRS against a fresh sf::st_crs() via sf::st_crs() == failed even for the identical CRS, because st_crs() couldn't recognize the truncated ellipsoid as standard WGS84. Fixed with digits = NA (full precision) everywhere this package serializes GeoJSON metadata back out. Also fixed: sf::st_crs() silently returns an NA CRS, with no warning or error, when given jsonlite::toJSON()'s "json"-classed return value directly instead of a plain character string; coerce with as.character() first. Changes in version 0.99.11 Bug fixes - st_as_sfc() on a DuckDBTable/DuckDBDataFrame unconditionally applied ST_GeomFromText/ST_GeomFromWKB/ST_GeomFromGeoJSON to every column, assuming the column was always stored as WKT/WKB/GeoJSON text needing conversion into GEOMETRY. Reported by a user calling st_as_sfc() on the result of readGeoParquet(), whose geometry column is already a native (and, since it round-tripped through GeoParquet, CRS-tagged, e.g. GEOMETRY('OGC:CRS84')) GEOMETRY type: ST_GeomFromText only accepts VARCHAR, so the query failed at materialization with a DuckDB binder error ("No function matches the given name and argument types 'ST_GeomFromText(GEOMETRY(...))'"), regardless of what CRS was set. st_as_sfc() now checks each column's type via coltypes() first and leaves already-GEOMETRY-typed columns untouched, only applying the WKT/WKB/GeoJSON conversion to columns that actually need it. Changes in version 0.99.10 New features - Added hasGeometry(x, geom = "geometry"): reported by a user (st_geometry_type(x) on a DuckDBTable with no geometry column didn't error -- it silently built a query applying ST_GeometryType to every column, including plain numeric/character ones, and only failed once that query was actually materialized, not when printed or built). That's not unique to st_geometry_type(): essentially every unary geometry accessor/predicate in DuckDBTable-spatial.R (st_is_valid, st_area, st_centroid, st_buffer, ...) is built on the same sql_call(x, "ST_*"), which applies its SQL function to all of x's columns with no upfront check that any of them are actually geometry-typed. Rather than retrofit validation into ~20 existing functions, added the one primitive needed to guard any of them: hasGeometry() checks whether x has a column named geom that is genuinely GEOMETRY-typed, returning FALSE (not an error) if it's missing or a different type. Built entirely on the already-exported DuckDBDataFrame::coltypes(), which already reports "geometry" as a distinct type value; no change to DuckDBDataFrame was needed. - readGeoParquet(path, geom = "geometry", ...) now warns (rather than silently returning non-spatial data) when path has no GEOMETRY-typed column matching geom, reported by the same user after noticing that reading an ordinary, non-spatial parquet file produced neither an error nor a warning. Built on hasGeometry() (above); the read itself still succeeds either way, since a mislabeled or already-non-spatial file is still valid tabular data. Changes in version 0.99.9 New features - .as_duckdb_table() (the in-memory materializer backing st_join/ st_join_table's sf/data.frame support, added in 0.99.8) now also accepts a plain WKT-text geometry column, not just sfc or raw WKB. MultiAssaySpatialExperiment's own idiomatic DataFrame shape (see its spatialJoin,DataFrame,DataFrame-method) stores geometry as WKT character strings, the same single-geometry shape .geom_to_sql() already parses, now generalized to a whole column via sf::st_as_sfc(). sf::st_as_sfc() errors outright on NA rather than tolerating it the way the sfg/WKB paths do, so an NA entry is substituted with "GEOMETRYCOLLECTION EMPTY" first (same never-matches-anything semantics as the NULL-handling added for the WKB-list case). Added regression tests covering a working WKT column, an NA entry, and genuinely unparseable WKT text. Changes in version 0.99.8 New features - Added st_join_table(x, y, join = st_intersects, sparse = TRUE): a sparse (id_x, id_y) row-pair analogue of the existing st_join.DuckDBTable, for two lazy DuckDBTable/DuckDBDataFrame layers. st_intersects_table() only ever supported testing x against a single reference geometry (its y goes through .geom_to_sql(), which has no case for another lazy table), so there was no way to get a sparse match table between two out-of-core layers short of materializing the full attribute join via st_join(). st_join_table() closes that gap with the same INNER JOIN ... ON (x.geometry, y.geometry) approach as st_join.DuckDBTable, honoring the join= predicate via the same .st_predicate_sql_name() mapping, just projecting row-pair ids instead of full attributes. Internally assigns row ids via the same __rowid__ alias convention st_intersects_table() already uses rather than id_x/id_y directly: an independent review before this shipped caught that the first draft used id_x/id_y as the internal alias too, so a table with its own pre-existing id_x/id_y data column (plausible, since that's exactly this function's own output name) would silently collide -- DuckDB auto-renames the duplicate rather than erroring, so the final result would silently return that stale data value instead of a row index, with no warning. Added a regression test using an injected colliding id_x/id_y column. - st_join.DuckDBTable/st_join_table now also accept an in-memory sf object (or a data.frame with an sfc or raw-WKB-list geometry column, the latter matching the shape as.data.frame() on a DuckDBDataFrame's own geometry column already produces) on either side, not just lazy tables, closing a real gap flagged by a user comparing against duckspatial::ddbs_intersects(). New internal .as_duckdb_table() materializes the in-memory side by converting its geometry to WKT (sf::st_as_text(), the same idiom .geom_to_sql() already uses for a single geometry) and copying it into a temp DuckDB table via dplyr::copy_to(), then casting back to native GEOMETRY with ST_GeomFromText(); the temp-table name uses the same PID+counter convention DuckDBArray::.duckdb_matmult_copy() already established to avoid the dbplyr::unique_table_name() global-RNG collision class fixed in DuckDBArray 0.99.9. Chosen over writeGeoParquet() + a tempfile (the only other working materialization path in this package) since that would pull in nanoparquet as a hard dependency (currently Suggests only) and add disk I/O for what's typically the small side of a join; CRS is not preserved either way, consistent with .geom_to_sql()'s existing CRS-less ST_GeomFromText() usage, so this isn't a new limitation. Also removed .spatialMatch_sql()'s dead else branch (DuckDBDataFrame-spatial.R): it attempted the same DuckDBDataFrame( as.data.frame(table)) call that didn't actually work (its only caller, layerSpatialMatch(), never reaches it with a non-DuckDBTable table, taking a separate in-memory sf::st_intersects() path instead), so it was unreachable, untested dead code. Bug fixes - Both vignettes, and the @examples in DuckDBColumn-spatial.R, DuckDBTable-spatial.R, and DuckDBDataFrame-spatial.R (regenerated into DuckDBColumn-spatial.Rd, DuckDBTable-spatial.Rd, and layerSpatialMatch.Rd), filtered a lazy column with df[which(!is.na(df$type)), ]. is.na()/! on a DuckDBColumn return another lazy DuckDBColumn (SQL-pushed), not a base logical vector, so which() errored with "argument to 'which' is not logical" and broke both R CMD build and R CMD check's example checks. DuckDBDataFrame's row-subset method already accepts a logical DuckDBColumn directly as i, pushing it down as a SQL WHERE filter, so which() was unnecessary; fixed to df[!is.na(df$type), ] everywhere. Changes in version 0.99.6 Documentation - Fixed two instances of `Type`s in the vignettes (a plural "s" immediately after a closing code-span backtick, e.g. "lazy `DuckDBColumn`s"), which renders with a visible gap that reads like a separate word "s". Reworded to "lazy DuckDBColumn objects" / "lazy DuckDBDataFrame objects" instead of moving the "s" inside the backticks, since neither class name is actually plural. Changes in version 0.99.5 Bug fixes - writeGeoParquet() wrote the GeoParquet crs metadata field as a raw WKT2 string instead of the PROJJSON object the GeoParquet 1.0.0 spec requires, which made DuckDB itself refuse to read back any file written with a CRS set ("Geoparquet column 'geometry' has invalid CRS"). Fixed via wk::wk_crs_projjson() (wk is already a transitive dependency via sf); added wk to Imports. Only surfaced once the writeGeoParquet() example was made to actually run (see Documentation below). Documentation - Added explanatory prose and links to sf documentation throughout both vignettes, for readers unfamiliar with sf: geometry columns/WKB, st_geometry_type()/st_area(), st_centroid()/WKT via st_as_text(), the st_point()/st_sfc() query-geometry idiom, WKT string literals passed to st_as_sfc(), and st_sf(). - Added runnable @examples to asCoordinateTransform(), st_affine(), and writeGeoParquet() (previously undocumented, or \dontrun-only). - writeGeoParquet.Rd's example switched from \dontrun to \donttest. - Added inst/scripts/make-extdata-spatial.R, documenting the bundled inst/extdata/spatial fixtures as hand-authored synthetic data (the canonical OGC/Wikipedia WKT example shapes for each geometry type, plus one EMPTY and one NULL geometry per type for edge-case testing), licensed under this package's own MIT license. Internal changes - Removed .st_point_sql(), dead code superseded by the exported st_point_sql(). Changes in version 0.99.4 Documentation - Replaced em dashes with commas or colons in the vignettes. Changes in version 0.99.3 Documentation - Briefly define "predicate" at its first use in the user and design vignettes (a true/false test of how two geometries relate), addressing the reviewer's note that the term may be unfamiliar to some readers. Changes in version 0.99.2 Documentation - Added URL and BugReports fields to DESCRIPTION. - Added a package-level man page (?DuckDBSpatial). - Removed the redundant library(BiocStyle) call from the vignettes (the BiocStyle::html_document output and ::-qualified helpers apply the style without loading the package). Applied suite-wide for consistency with the Bioconductor review of DuckDBDataFrame. Changes in version 0.9.12 New features - 3-D coord-indexed points. spatialSortPoints() and writeSpatialPointsParquet() gain a z_col argument and cluster on a genuine 3-D Morton curve zorder(c(x, y, z)) (the shared generator is already N-D — not a 2-D curve with z appended). The writer auto-detects a "z" column by default (so 3-D points cluster in 3-D automatically, matching scibis's writer and keeping the points Parquet byte-identical across the two stacks); z_col = NA forces 2-D, a name overrides. layerBboxRange() gains zmin/zmax (and z_col): when both are supplied it ANDs a z BETWEEN term that pushes into the Parquet scan too, so a 3-D layout prunes row groups on all three axes. Still a pure row permutation + plain range predicate — no column added, no secondary index. Changes in version 0.9.11 New features - Coordinate-transform operators + a coordinate-transform graph, closing the largest OME-NGFF / spatialdataR parity gap (previously only st_flip_coordinates + CRS metadata). - A transform algebra (coordinate-transforms.R): ctIdentity(), ctScale(), ctTranslation(), ctRotation(), ctAffine(), ctSequence(), ctMapAxis(), ctByDimension(), ctBijection() build the OME-NGFF RFC-5 affine family; ctAffineMatrix() lowers any transform to a homogeneous affine matrix, ctApply() applies it to a matrix of points, and ctInvert() inverts it. The full matrix-expressible RFC-5 conformance suite (incl. 3-D, dimensionality change, and multi-hop paths) is vendored as point-level vectors and passes. - A coordinate-transform graph (coordinate-transform-graph.R): coordinateSystem(), ctGraph() (auto-adds inverse edges for invertible transforms), ctPath() (shortest-path resolution; errors on unknown systems, no path, or an ambiguous tie), and ctBetween() (resolve + apply). Base R only -- no graph/RBGL dependency. - DuckDB data application: st_affine() transforms a DuckDBTable / DuckDBColumn geometry column via ST_Affine, and transformLayer() applies a (2-D) coordinate transform to a lazy spatial layer -- point x/y columns by arithmetic, a geometry column by ST_Affine. Displacement / coordinate-field ("by path") transforms are out of scope. - Coord-indexed points layout for fast viewport queries (points-coord-index.R). A viewport query is a bounding-box range predicate on (x, y). Sorting points along a space-filling curve before writing gives each Parquet row group a tight x/y zonemap, so DuckDB prunes the groups outside the box and reads only the points the query needs. - spatialSortPoints() reorders a points table by the Morton (Z-order) code of its (x, y): a pure row permutation that clusters spatial neighbours and round-trips identically. - writeSpatialPointsParquet() sorts (by default) and writes a points Parquet with a bounded ROW_GROUP_SIZE, so there are row groups to prune; spatial_sort = FALSE writes the acquisition-order baseline. - layerBboxRange() subsets a DuckDBDataFrame point layer to a bounding box with a plain x/y BETWEEN predicate that pushes into the Parquet scan and prunes, unlike layerSubsetByBbox(), which builds a per-row ST_Point and tests ST_Intersects. Returns a lazy DuckDBDataFrame. This is the 2-D spatial case of DuckDBDataFrame's general cluster_by directive: spatialSortPoints() delegates to DuckDBDataFrame::clusterSort() with DuckDBDataFrame::zorder(), so the stack keeps a single Morton generator. Changes in version 0.9.10 Changes - Relicensed under the MIT License. Changes in version 0.9.9 Bug fixes - Loading the package now installs and loads the DuckDB spatial extension on the shared DuckDBDataFrame connection (via DuckDBDataFrame::loadExtension() in .onLoad). Every DuckDBSpatial operation compiles to ST_* SQL resolved against that connection, and DuckDB's autoload did not reliably install the extension (e.g. in a fresh R CMD check environment), so ST_* calls failed with "… is not in the catalog, but it exists in the spatial extension". The install is best-effort (optional = TRUE) and silent: where the extension cannot be obtained (offline / restricted network / TLS interception) package loading still succeeds without emitting any warning or message, and spatial operations error only when actually used (with DuckDB's own guidance). To pre-seed in a restricted environment, place a version-matched spatial.duckdb_extension under DUCKDB_EXTENSION_DIRECTORY, or point BIOCDUCKDB_EXTENSION_REPOSITORY at a reachable mirror. - st_join() on a DuckDBTable now honors its join predicate argument instead of always using ST_Intersects. The predicate function is mapped to the matching DuckDB ST_* function (st_within -> ST_Within, st_contains -> ST_Contains, etc.); an unrecognized predicate errors rather than silently falling back to intersects. - writeGeoParquet() now records the geometry column's CRS (WKT2) in the GeoParquet metadata. Previously the crs key was omitted, so readers fell back to the spec default of OGC:CRS84 (WGS84 lon/lat) and silently mislabeled projected data. - writeGeoParquet() now omits the bbox metadata when the extent is unknown (empty / non-finite geometry), per the GeoParquet spec, instead of writing a false [0, 0, 0, 0] extent at the origin that would mis-prune bbox-based spatial filters. Changes in version 0.9.8 Documentation - Made the vignettes resilient to a missing DuckDB spatial extension: a setup probe (.spatial_ok) gates the live spatial chunks, so R CMD build and the modl-docs render succeed (with a short note) where the extension cannot be obtained (e.g. an offline developer machine or a restricted CI network), and render the examples for real where it is available. Changes in version 0.9.7 Documentation - Restructured the vignettes into a user-first set, replacing the single Overview of the DuckDBSpatial Package: - Introduction to DuckDBSpatial --- motivation, lazy spatial columns, predicates and st_filter(), the layer-level engines for coordinate columns, and GeoParquet I/O. - Design and extension of DuckDBSpatial --- how the sf generics translate to DuckDB spatial SQL, the two dispatch paths (geometry columns vs coordinate columns), GeoParquet 1.0 I/O, and the BiocDuckDB / MultiAssaySpatialExperiment integration, for developers. - Rewrote the README.