Materializes a lazy sedonadb_dataframe into an R sf object. Checks row count against a safety threshold before downloading to prevent crashes from massive datasets.
Arguments
- x
A
sedonadb_dataframe,sfobject, or view name (character) in SedonaDB to be collected.- force
Logical. If
TRUE, bypasses the row count safety check when collecting data via[sx_collect()]. Use with caution on large datasets.- verbosity
Character or NULL. Controls message output for this function call.
"quiet": Suppress all informational messages."info": Show standard progress and status messages."debug": Show additional diagnostic messages for troubleshooting.
If NULL (the default), uses the global
sx.verbosityoption. Seesx_options()for persistent configuration.
Examples
# \donttest{
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
# Load sample data
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
box <- st_bbox(nc[1:10, ]) |> st_as_sfc() |> st_as_sf()
# -------------------------------------------------------------------
# Example 1: Collect from sedonadb_dataframe (lazy result)
# -------------------------------------------------------------------
lazy_result <- sx_filter(nc, box, output = "lazy")
sf_result <- sx_collect(lazy_result)
class(sf_result) # "sf"
#> [1] "sf" "data.frame"
# -------------------------------------------------------------------
# Example 2: Collect from a named view
# -------------------------------------------------------------------
sx_as_view(nc, "nc_data")
sf_from_view <- sx_collect("nc_data")
# ---
# Note: sx_collect has a safety limit (default 1M rows).
# Use force = TRUE to bypass if you're sure about memory capacity:
# sx_collect(large_lazy_result, force = TRUE)
# }
