if (FALSE) {
## load packages
library(duckspatial)
library(sf)
# create points data
n <- 5
points_sf <- data.frame(
id = 1,
x = runif(n, min = -180, max = 180),
y = runif(n, min = -90, max = 90)
) |>
sf::st_as_sf(coords = c("x", "y"), crs = 4326) |>
st_geometry() |>
st_combine() |>
st_cast("MULTIPOINT") |>
st_as_sf()
# option 1: passing sf objects
output1 <- duckspatial::ddbs_concave_hull(x = points_sf)
plot(output1)
# 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, points_sf, "points_tbl")
# spatial join
output2 <- duckspatial::ddbs_concave_hull(
conn = conn,
x = "points_tbl"
)
plot(output2)
}
Run the code above in your browser using DataLab