tests/testthat/setup.R

# skip tests on CRAN because they take too much time
# skip_if(Sys.getenv("TEST_ONE") != "")
# testthat::skip_on_cran()
testthat::skip_if_not_installed("duckdb")

## Try to limit threads
Sys.setenv("OMP_THREAD_LIMIT" = 2)

# read polygons data from duckspatial package
countries_sf <- sf::st_read(system.file("spatial/countries.geojson", package = "duckspatial")) |> 
    sf::st_transform("EPSG:4326")
countries_sf <- subset(countries_sf, CNTR_ID %in% c("AR", "BR", "BO", "PE", "PY", "UY", "CL"))
argentina_sf <- sf::st_read(system.file("spatial/argentina.geojson", package = "duckspatial")) |> 
    sf::st_transform("EPSG:4326")
argentina_ddbs <- duckspatial::as_duckspatial_df(argentina_sf)
countries_ddbs <- duckspatial::as_duckspatial_df(countries_sf)

# read lines data
rivers_sf <- sf::st_read(system.file("spatial/rivers.geojson", package = "duckspatial")) |> 
    sf::st_transform("EPSG:3035")
rivers_ddbs <- duckspatial::ddbs_open_dataset(system.file("spatial/rivers.geojson", package = "duckspatial"))

## create points data
set.seed(42)
n <- 1000
points_sf <- data.frame(
    id = 1:n,
    x = runif(n, min = -180, max = 180),
    y = runif(n, min = -90, max = 90)
) |>
    sf::st_as_sf(coords = c("x", "y"), crs = 4326)

points_ddbs <- duckspatial::as_duckspatial_df(points_sf)

# North Carolina data from sf package - used by duckspatial_df tests
nc_sf   <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_ddbs <- duckspatial::ddbs_open_dataset(system.file("shape/nc.shp", package = "sf"))

Try the duckspatial package in your browser

Any scripts or data that you put into this service are public.

duckspatial documentation built on June 22, 2026, 9:08 a.m.