NIEHS / chopin

Scalable GIS methods for environmental and climate data analysis
https://niehs.github.io/chopin/
Other
6 stars 2 forks source link

Align input-output class in `par_make_gridset(..., mode="grid_advanced")` #67

Closed sigmafelix closed 2 months ago

sigmafelix commented 3 months ago

Error description

Unlike other mode setting in par_make_gridset, par_make_gridset(..., mode="grid_advanced") returns a list of SpatVector.

Reproducible code

library(sf)
library(terra)
library(tigris)
library(chopin)
library(spatstat.random)
set.seed(2024)
# Read the nc example gpkg file from sf package
nc <- st_read(system.file("gpkg/nc.gpkg", package = "sf"))
nc <- st_transform(nc, 5070)

# Sample clustered points using st_sample (input is sf)
sampled_points <- st_sample(nc, type = "Thomas", mu = 3e-9, scale = 1000, kappa = 10)

# grid merge
grid_merge <- chopin::par_make_gridset(sampled_points, mode = "grid_advanced", nx = 24L, ny = 12L, grid_min_features = 30L, padding = 2e4)
plot(sampled_points$geom, pch = 19, cex = 0.2)
plot(grid_merge$padded$geometry, add = TRUE, border = "red", lwd = 2)

class(grid_merge)
# output is SpatVectors

Expected behavior

Input and output are supposed to be the same class.

sessionInfo() results

N/A: does not depend on local systems.