# \donttest{
lastpar <- par(mfrow = c(1, 1))
library(sf)
library(mirai)
options(sf_use_s2 = FALSE)
daemons(4, dispatcher = "process")
ncpath <- system.file("shape/nc.shp", package = "sf")
ncpoly <- sf::st_read(ncpath)
ncpoly <- sf::st_transform(ncpoly, "EPSG:5070")
# sf object
ncpnts <-
sf::st_sample(ncpoly, 2000)
ncpnts <- sf::st_as_sf(ncpnts)
ncpnts$pid <- seq_len(nrow(ncpnts))
# file path
rrast <- terra::rast(ncpoly, nrow = 600, ncol = 1320)
terra::values(rrast) <- rgamma(7.92e5, 4, 2)
# Using raster path
rastpath <- file.path(tempdir(), "ncelev.tif")
terra::writeRaster(rrast, rastpath, overwrite = TRUE)
nccompreg <-
chopin::par_pad_grid(
input = ncpnts,
mode = "grid",
nx = 4L,
ny = 2L,
padding = 5e3L
)
res <-
par_grid_mirai(
grids = nccompreg,
fun_dist = extract_at,
x = rastpath,
y = ncpnts,
qsegs = 90L,
radius = 5e3L,
id = "pid"
)
mirai::daemons(0L)
par(lastpar)
# }
Run the code above in your browser using DataLab