
Collect a duckspatial_df with flexible output formats
Source:R/duckspatial_df_dplyr_methods.R, R/duckspatial_df_sf_methods.R
ddbs_collect.RdMaterializes a lazy duckspatial_df object by executing the underlying
DuckDB query. Supports multiple output formats.
Usage
# S3 method for class 'duckspatial_df'
collect(x, ..., as = NULL)
ddbs_collect(x, ..., as = c("sf", "tibble", "raw", "geoarrow"))Arguments
- x
A
duckspatial_dfobject- ...
Additional arguments passed to
collect- as
Output format. One of:
"sf"(Default) Returns an
sfobject withsfcgeometry"tibble"Returns a tibble with geometry column dropped (fastest)
"raw"Returns a tibble with geometry as raw WKB bytes
"geoarrow"Returns a tibble with geometry as
geoarrow_vctr
Examples
if (FALSE) { # \dontrun{
library(duckspatial)
# Load lazy spatial data
nc <- ddbs_open_dataset(system.file("shape/nc.shp", package = "sf"))
# Perform lazy operations
result <- nc |> dplyr::filter(AREA > 0.1)
# Collect to sf (default)
result_sf <- ddbs_collect(result)
plot(result_sf["AREA"])
# Collect as tibble without geometry (fast)
result_tbl <- ddbs_collect(result, as = "tibble")
# Collect with raw WKB bytes
result_raw <- ddbs_collect(result, as = "raw")
# Collect as geoarrow for Arrow workflows
result_ga <- ddbs_collect(result, as = "geoarrow")
} # }