if (FALSE) {
## load packages
library(duckspatial)
library(sf)
# create a duckdb database in memory (with spatial extension)
conn <- ddbs_create_conn(dbdir = "memory")
# read data
argentina_sf <- st_read(system.file("spatial/argentina.geojson", package = "duckspatial"))
# option 1: passing sf objects
output1 <- duckspatial::ddbs_convex_hull(x = argentina_sf)
plot(output1["CNTR_NAME"])#' # store in duckdb
# option 2: passing the name of a table in a duckdb db
# creates a duckdb
conn <- duckspatial::ddbs_create_conn()
# write sf to duckdb
ddbs_write_vector(conn, argentina_sf, "argentina_tbl")
# spatial join
output2 <- duckspatial::ddbs_convex_hull(
conn = conn,
x = "argentina_tbl"
)
plot(output2["CNTR_NAME"])
}
Run the code above in your browser using DataLab