diff --git a/tools/test-coverage-local.yaml b/.github/workflows/test-coverage-local.yaml
similarity index 68%
rename from tools/test-coverage-local.yaml
rename to .github/workflows/test-coverage-local.yaml
index 2649e14..b354944 100644
--- a/tools/test-coverage-local.yaml
+++ b/.github/workflows/test-coverage-local.yaml
@@ -1,14 +1,11 @@
-# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
-# also derived from https://github.com/we-cli/coverage-badge-action
-# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
+name: test-coverage-local
+
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
-name: test-coverage-local
-
jobs:
test-coverage:
runs-on: ubuntu-latest
@@ -43,7 +40,6 @@ jobs:
covr::report(covpack, file = file.path('${{ github.workspace }}', 'chopin-coverage-report.html')); \
covd<-covr::coverage_to_list(covpack)$totalcoverage; \
write.table(covd[length(covd)], file = '${{ github.workspace }}/local_cov.Rout', row.names = F, col.names = F)"
- shell: bash
- name: Upload covr report as artifact
uses: actions/upload-artifact@v4
@@ -65,32 +61,29 @@ jobs:
COV=$(cat ${{ github.workspace }}/local_cov.Rout)
echo "coverage=$COV" >> $GITHUB_OUTPUT
- - name: Checkout gh-pages
- uses: actions/checkout@v4
- with:
- ref: gh-pages
-
- name: Create Badges
shell: bash
run: |
npm i -g badgen-cli
export COV=${{ steps.get-values.outputs.coverage }}
- COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `orange`')
+ COLOR=$(node -p '+process.env.COV >= 95 ? "green" : "orange"')
mkdir -p badges
badgen -j coverage -s $COV% -c $COLOR > badges/coverage.svg
-
- - name: Deploy Badges
- uses: stefanzweifel/git-auto-commit-action@v4
- with:
- commit_message: "Update badges [skip ci]"
- branch: gh-pages
- skip_fetch: true
- skip_checkout: true
-
- # Without this, will get Error:
- # Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/coverage-badge-action/coverage-badge-action/action.yml'.
- # Did you forget to run actions/checkout before running your local action?
- - name: Checkout Back
+
+ - name: Checkout artifacts branch
uses: actions/checkout@v4
with:
- ref: ${{ github.ref }}
+ ref: artifacts
+ path: artifact-branch # Add a path to avoid conflicts with main checkout
+
+ - name: Commit and Push Badge to Artifacts Branch
+ run: |
+ cd artifact-branch
+ git config --global user.name "github-actions[bot]"
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
+ mkdir -p actions/workflows/test-coverage-local.yaml
+ cp ../badges/coverage.svg actions/workflows/test-coverage-local.yaml/
+ git add actions/workflows/test-coverage-local.yaml/coverage.svg
+ git commit -m "Update coverage badge [skip ci]" || echo "No changes to commit"
+ git push origin artifacts
+ if: success()
\ No newline at end of file
diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml
deleted file mode 100644
index c0d6c44..0000000
--- a/.github/workflows/test-coverage.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
-# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
-on:
- push:
- branches: [main, master]
- pull_request:
- branches: [main, master]
-
-name: test-coverage
-
-permissions: read-all
-
-jobs:
- test-coverage:
- runs-on: ubuntu-latest
- env:
- GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
-
- steps:
- - uses: actions/checkout@v4
-
- - uses: r-lib/actions/setup-r@v2
- with:
- use-public-rspm: true
-
- - uses: r-lib/actions/setup-r-dependencies@v2
- with:
- extra-packages: any::covr
- needs: coverage
-
- - name: Test coverage
- run: |
- cov <- covr::package_coverage(
- quiet = FALSE,
- clean = FALSE,
- install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
- )
- covr::to_cobertura(cov)
- shell: Rscript {0}
-
- - uses: codecov/codecov-action@v4
- with:
- fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
- file: ./cobertura.xml
- plugin: noop
- disable_search: true
- token: ${{ secrets.CODECOV_TOKEN }}
-
- - name: Show testthat output
- if: always()
- run: |
- ## --------------------------------------------------------------------
- find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
- shell: bash
-
- - name: Upload test results
- if: failure()
- uses: actions/upload-artifact@v4
- with:
- name: coverage-test-failures
- path: ${{ runner.temp }}/package
\ No newline at end of file
diff --git a/NEWS.md b/NEWS.md
index 708a3cf..a569dc4 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,5 @@
# 0.9
- `mirai` based `par_*` functions for parallelization
-- terra::extract mode in `extract_at()` with `terra` argument and auxiliary arguments including exact, weights, touches
# 0.8
- Bumped version from 0.7.8 to 0.8.0: improving package coverage
diff --git a/R/chopin-package.R b/R/chopin-package.R
index 72719fb..d4a2e2c 100644
--- a/R/chopin-package.R
+++ b/R/chopin-package.R
@@ -9,7 +9,7 @@
## usethis namespace: start
#' @importFrom lifecycle deprecated
#' @section Basic functionalities:
-#' * Distribute `terra`, `sf`, and `chopin` functions to parallel workers set by `future`
+#' * Distribute `terra`, `sf`, and `chopin` functions to parallel workers set by `future` or `mirai`
#' * Set parallelization strategies based on artificial grids, equal-size clusters, hierarchy, and multiple raster files
#' * Convenience functions for raster-vector overlay and weighted summary from vector dataset
#'
diff --git a/R/processing.R b/R/processing.R
index 6996c43..3a92149 100644
--- a/R/processing.R
+++ b/R/processing.R
@@ -52,7 +52,6 @@ kernelfunction <-
y_vec,
id,
extracted,
- terra = FALSE,
kernel_func = stats::weighted.mean,
kernel = NULL,
bandwidth = NULL,
@@ -71,17 +70,11 @@ kernelfunction <-
)
y_vec <- terra::centroids(y_vec, inside = TRUE)
}
- if (!terra) {
- name_surf_val <-
- ifelse(terra::nlyr(x_ras) == 1,
- "value", names(x_ras))
- } else {
- # TODO: "ID", "x", "y" are too generic to exclude;
- # need to find a generalized way of excluding names
- exclude_vec <- c("id_chopin", "coverage_fraction", "ID", "x", "y")
- exclude_vec <- append(exclude_vec, names(y_vec))
- name_surf_val <- setdiff(names(extracted), exclude_vec)
- }
+
+ name_surf_val <-
+ ifelse(terra::nlyr(x_ras) == 1,
+ "value", names(x_ras))
+
# convert to data.frame
coords_df <- as.data.frame(y_vec, geom = "XY")
# apply strict order
@@ -138,8 +131,6 @@ kernelfunction <-
#' @param id character(1). Name of unique identifier field.
#' @param func character(1)/function. supported function names or functions
#' taking `x` and `w` in `exactextractr::exact_extract`
-#' @param terra logical(1). If `TRUE`, use `terra::extract` instead of
-#' `exactextractr::exact_extract`.
#' @param extent numeric. Passed to .check_vector
#' @param radius numeric(1). Buffer radius.
#' @param out_class character(1). "sf" or "terra"
@@ -152,9 +143,6 @@ kernelfunction <-
#' @param .standalone logical(1). Whether or not running standalone mode.
#' `TRUE` will apply internal input check functions, whereas
#' `FALSE` will let `par_*` functions will check inputs.
-#' @param weights passed to `terra::extract()` Default is TRUE.
-#' @param exact passed to `terra::extract()` Default is TRUE.
-#' @param touches passed to `terra::extract()` Default is FALSE.
#' @keywords internal
#' @noRd
.extract_at <- function(
@@ -162,7 +150,6 @@ kernelfunction <-
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -170,9 +157,6 @@ kernelfunction <-
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = NULL,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
@@ -192,7 +176,7 @@ kernelfunction <-
)
# reproject polygons to raster's crs
y <- reproject_to_raster(vector = y, raster = x)
- if (dep_check(y) == "terra" && !terra) {
+ if (dep_check(y) == "terra") {
y <- dep_switch(y)
}
}
@@ -208,40 +192,20 @@ kernelfunction <-
}
iskernel <- !is.null(kernel)
- if (!terra) {
- extracted <-
- exactextractr::exact_extract(
- x = x,
- y = y,
- fun = if (iskernel) NULL else func,
- force_df = TRUE,
- stack_apply = !iskernel,
- append_cols = if (iskernel) NULL else id,
- include_cols = if (iskernel) id else NULL,
- progress = FALSE,
- include_area = iskernel,
- include_xy = iskernel,
- max_cells_in_memory = max_cells
- )
- } else {
- extracted <-
- terra::extract(
- x = x, y = y,
- fun = if (iskernel) NULL else func,
- xy = TRUE,
- weights = weights,
- exact = exact,
- touches = touches,
- bind = TRUE,
- ID = TRUE
- )
-
- extracted[[id]] <- y[[id]][extracted$ID]
- extracted$ID <- NULL
- names(extracted)[names(extracted) == "id_chopin"] <- id
- names(extracted)[names(extracted) %in% c("weight", "fraction")] <-
- "coverage_fraction"
- }
+ extracted <-
+ exactextractr::exact_extract(
+ x = x,
+ y = y,
+ fun = if (iskernel) NULL else func,
+ force_df = TRUE,
+ stack_apply = !iskernel,
+ append_cols = if (iskernel) NULL else id,
+ include_cols = if (iskernel) id else NULL,
+ progress = FALSE,
+ include_area = iskernel,
+ include_xy = iskernel,
+ max_cells_in_memory = max_cells
+ )
if (iskernel) {
stopifnot(!is.null(bandwidth))
@@ -255,7 +219,6 @@ kernelfunction <-
y_vec = y,
id = id,
extracted = extracted,
- terra = terra,
kernel = kernel,
kernel_func = kernel_func,
bandwidth = bandwidth
@@ -284,8 +247,6 @@ kernelfunction <-
#' @param func function taking one numeric vector argument.
#' Default is `"mean"` for all supported signatures in arguments
#' `x` and `y`.
-#' @param terra logical(1). If `TRUE`, use `terra::extract` instead of
-#' `exactextractr::exact_extract`.
#' @param extent numeric(4) or SpatExtent. Extent of clipping vector.
#' It only works with `points` of character(1) file path.
#' @param radius numeric(1). Buffer radius.
@@ -297,9 +258,6 @@ kernelfunction <-
#' Default is [`stats::weighted.mean()`]
#' @param bandwidth numeric(1). Kernel bandwidth.
#' @param max_cells integer(1). Maximum number of cells in memory.
-#' @param weights passed to `terra::extract()` Default is TRUE.
-#' @param exact passed to `terra::extract()` Default is TRUE.
-#' @param touches passed to `terra::extract()` Default is FALSE.
#' @param .standalone logical(1). Default is `TRUE`, which means that
#' the function will be executed in a standalone mode.
#' When using this function in `par_*` functions,
@@ -351,7 +309,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -359,15 +316,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -375,9 +328,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
@@ -397,7 +347,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -405,15 +354,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -421,9 +366,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
@@ -443,7 +385,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -451,15 +392,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -467,9 +404,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
@@ -488,7 +422,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -496,15 +429,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -512,9 +441,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
@@ -534,7 +460,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -542,15 +467,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -558,9 +479,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
@@ -581,7 +499,6 @@ setMethod(
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -589,15 +506,11 @@ setMethod(
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
) {
.extract_at(
x = x, y = y, id = id, func = func,
- terra = terra,
extent = extent,
radius = radius,
out_class = out_class,
@@ -605,9 +518,6 @@ setMethod(
kernel_func = kernel_func,
bandwidth = bandwidth,
max_cells = max_cells,
- exact = exact,
- weights = weights,
- touches = touches,
.standalone = .standalone
)
}
diff --git a/R/scale_process_mirai.R b/R/scale_process_mirai.R
index 103fdb0..a5f322b 100644
--- a/R/scale_process_mirai.R
+++ b/R/scale_process_mirai.R
@@ -71,6 +71,7 @@
#' radius = 5e3L,
#' id = "pid"
#' )
+#' mirai::daemons(0L)
#' @seealso
#' [`mirai::daemons`], [`mirai::mirai_map`], [`par_convert_f`]
#' @importFrom mirai mirai_map
@@ -354,6 +355,7 @@ par_grid_mirai <-
#' func = "mean",
#' .debug = TRUE
#' )
+#' mirai::daemons(0L)
#' @importFrom rlang inject !!!
#' @importFrom mirai mirai_map
#' @importFrom collapse rowbind
@@ -680,6 +682,7 @@ par_hierarchy_mirai <-
#' id = "GEOID",
#' func = "mean"
#' )
+#' mirai::daemons(0L)
#' @importFrom mirai mirai_map
#' @importFrom terra rast
#' @importFrom rlang inject !!!
diff --git a/README.Rmd b/README.Rmd
index ef43e5f..43b3368 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -14,16 +14,17 @@ knitr::opts_chunk$set(
)
```
-# Computation of Spatial Data by Hierarchical and Objective Partitioning of Inputs for Parallel Processing
+# Computation of Spatial Data by Hierarchical and Objective Partitioning of Inputs for Parallel Processing
-[![Codecov test
-coverage](https://codecov.io/gh/ropensci/chopin/graph/badge.svg)](https://app.codecov.io/gh/chopin/osmapiR)
-
+
+![Coverage](https://github.com/ropensci/chopin/actions/workflows/test-coverage-local.yaml/coverage.svg)
[![R-CMD-check](https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml)
[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/638_status.svg)](https://github.com/ropensci/software-review/issues/638)
+[![runiverse-package](https://ropensci.r-universe.dev/badges/chopin?scale=1&color=pink&style=round)](https://ropensci.r-universe.dev/chopin)
+[![Docs](https://img.shields.io/badge/docs-release-blue.svg)](https://docs.ropensci.org/chopin/)
[![Lifecycle:
-experimental](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
+stable](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
diff --git a/README.md b/README.md
index 815b352..dcc95ed 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,18 @@
-# Computation of Spatial Data by Hierarchical and Objective Partitioning of Inputs for Parallel Processing
+# Computation of Spatial Data by Hierarchical and Objective Partitioning of Inputs for Parallel Processing
-[![Codecov test
-coverage](https://codecov.io/gh/ropensci/chopin/graph/badge.svg)](https://app.codecov.io/gh/chopin/osmapiR)
-
+
+
+![Coverage](https://github.com/ropensci/chopin/actions/workflows/test-coverage-local.yaml/coverage.svg)
[![R-CMD-check](https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml)
[![Status at rOpenSci Software Peer
Review](https://badges.ropensci.org/638_status.svg)](https://github.com/ropensci/software-review/issues/638)
+[![runiverse-package](https://ropensci.r-universe.dev/badges/chopin?scale=1&color=pink&style=round)](https://ropensci.r-universe.dev/chopin)
+[![Docs](https://img.shields.io/badge/docs-release-blue.svg)](https://docs.ropensci.org/chopin/)
[![Lifecycle:
-experimental](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
+stable](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
@@ -263,7 +265,7 @@ system.time(
)
#> Input is a character. Attempt to read it with terra::rast...
#> user system elapsed
-#> 5.009 0.067 4.719
+#> 5.458 0.088 5.580
```
#### Generate regular grid computational regions
@@ -350,7 +352,7 @@ system.time(
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Task at CGRIDID: 4 is successfully dispatched.
#> user system elapsed
-#> 0.325 0.023 7.433
+#> 0.336 0.045 7.788
ncpoints_srtm <-
extract_at(
@@ -408,7 +410,7 @@ system.time(
)
#> ℹ Input is not a character.
#> user system elapsed
-#> 0.074 0.000 9.284
+#> 0.083 0.000 8.004
# remove mirai::daemons
mirai::daemons(0L)
@@ -437,7 +439,7 @@ path_nchrchy <- file.path(wdir, "nc_hierarchy.gpkg")
nc_data <- path_nchrchy
nc_county <- sf::st_read(nc_data, layer = "county")
#> Reading layer `county' from data source
-#> `/tmp/RtmpXuCaOL/temp_libpath358e3adc6f09/chopin/extdata/nc_hierarchy.gpkg'
+#> `/tmp/RtmpmJUPd2/temp_libpath3b3aa268543/chopin/extdata/nc_hierarchy.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 100 features and 1 field
#> Geometry type: POLYGON
@@ -446,7 +448,7 @@ nc_county <- sf::st_read(nc_data, layer = "county")
#> Projected CRS: NAD83 / Conus Albers
nc_tracts <- sf::st_read(nc_data, layer = "tracts")
#> Reading layer `tracts' from data source
-#> `/tmp/RtmpXuCaOL/temp_libpath358e3adc6f09/chopin/extdata/nc_hierarchy.gpkg'
+#> `/tmp/RtmpmJUPd2/temp_libpath3b3aa268543/chopin/extdata/nc_hierarchy.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 2672 features and 1 field
#> Geometry type: MULTIPOLYGON
@@ -476,7 +478,7 @@ system.time(
)
#> Input is a character. Attempt to read it with terra::rast...
#> user system elapsed
-#> 0.527 0.000 0.491
+#> 0.621 0.010 0.613
# hierarchical parallelization
system.time(
@@ -594,7 +596,7 @@ system.time(
#> Input is a character. Attempt to read it with terra::rast...ℹ Your input function at 37055 is dispatched.
#> Input is a character. Attempt to read it with terra::rast...ℹ Your input function at 37047 is dispatched.
#> user system elapsed
-#> 0.396 0.041 7.102
+#> 0.419 0.033 7.799
```
### `par_multirasters()`: parallelize over multiple rasters
@@ -621,9 +623,9 @@ terra::writeRaster(ncelev, file.path(tdir, "test5.tif"), overwrite = TRUE)
# check if the raster files were exported as expected
testfiles <- list.files(tdir, pattern = "*.tif$", full.names = TRUE)
testfiles
-#> [1] "/tmp/Rtmpe3n6BN/test1.tif" "/tmp/Rtmpe3n6BN/test2.tif"
-#> [3] "/tmp/Rtmpe3n6BN/test3.tif" "/tmp/Rtmpe3n6BN/test4.tif"
-#> [5] "/tmp/Rtmpe3n6BN/test5.tif"
+#> [1] "/tmp/RtmpiW9fAm/test1.tif" "/tmp/RtmpiW9fAm/test2.tif"
+#> [3] "/tmp/RtmpiW9fAm/test3.tif" "/tmp/RtmpiW9fAm/test4.tif"
+#> [5] "/tmp/RtmpiW9fAm/test5.tif"
```
``` r
@@ -640,32 +642,32 @@ system.time(
)
#> ℹ Input is not a character.
#> Input is a character. Attempt to read it with terra::rast...
-#> ℹ Your input function at /tmp/Rtmpe3n6BN/test1.tif is dispatched.
+#> ℹ Your input function at /tmp/RtmpiW9fAm/test1.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
-#> ℹ Your input function at /tmp/Rtmpe3n6BN/test2.tif is dispatched.
+#> ℹ Your input function at /tmp/RtmpiW9fAm/test2.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
-#> ℹ Your input function at /tmp/Rtmpe3n6BN/test3.tif is dispatched.
+#> ℹ Your input function at /tmp/RtmpiW9fAm/test3.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
-#> ℹ Your input function at /tmp/Rtmpe3n6BN/test4.tif is dispatched.
+#> ℹ Your input function at /tmp/RtmpiW9fAm/test4.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
-#> ℹ Your input function at /tmp/Rtmpe3n6BN/test5.tif is dispatched.
+#> ℹ Your input function at /tmp/RtmpiW9fAm/test5.tif is dispatched.
#> user system elapsed
-#> 1.329 0.087 2.830
+#> 1.288 0.090 2.901
knitr::kable(head(res))
```
| mean | base\_raster |
| --------: | :------------------------ |
-| 136.80203 | /tmp/Rtmpe3n6BN/test1.tif |
-| 189.76170 | /tmp/Rtmpe3n6BN/test1.tif |
-| 231.16968 | /tmp/Rtmpe3n6BN/test1.tif |
-| 98.03845 | /tmp/Rtmpe3n6BN/test1.tif |
-| 41.23463 | /tmp/Rtmpe3n6BN/test1.tif |
-| 270.96933 | /tmp/Rtmpe3n6BN/test1.tif |
+| 136.80203 | /tmp/RtmpiW9fAm/test1.tif |
+| 189.76170 | /tmp/RtmpiW9fAm/test1.tif |
+| 231.16968 | /tmp/RtmpiW9fAm/test1.tif |
+| 98.03845 | /tmp/RtmpiW9fAm/test1.tif |
+| 41.23463 | /tmp/RtmpiW9fAm/test1.tif |
+| 270.96933 | /tmp/RtmpiW9fAm/test1.tif |
``` r
@@ -701,7 +703,7 @@ pnts <- sf::st_as_sf(pnts)
pnts$pid <- sprintf("RPID-%04d", seq(1, 5000))
rd1 <- sf::st_read(path_ncrd1)
#> Reading layer `ncroads_first' from data source
-#> `/tmp/RtmpXuCaOL/temp_libpath358e3adc6f09/chopin/extdata/ncroads_first.gpkg'
+#> `/tmp/RtmpmJUPd2/temp_libpath3b3aa268543/chopin/extdata/ncroads_first.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 620 features and 4 fields
#> Geometry type: MULTILINESTRING
@@ -754,11 +756,11 @@ system.time(
restr <- terra::nearest(x = terra::vect(pntst), y = terra::vect(rd1t))
)
#> user system elapsed
-#> 0.38 0.00 0.36
+#> 0.396 0.000 0.397
pnt_path <- file.path(tdir, "pntst.gpkg")
sf::st_write(pntst, pnt_path)
-#> Writing layer `pntst' to data source `/tmp/Rtmpe3n6BN/pntst.gpkg' using driver `GPKG'
+#> Writing layer `pntst' to data source `/tmp/RtmpiW9fAm/pntst.gpkg' using driver `GPKG'
#> Writing 5000 features with 1 fields and geometry type Point.
# we use four threads that were configured above
@@ -804,7 +806,7 @@ system.time(
#> ℹ Input is a character. Trying to read with terra .
#> ℹ Task at CGRIDID: 8 is successfully dispatched.
#> user system elapsed
-#> 0.066 0.000 0.374
+#> 0.058 0.010 0.401
```
- We will compare the results from the single-thread and multi-thread
diff --git a/codemeta.json b/codemeta.json
index efb7f38..1437945 100644
--- a/codemeta.json
+++ b/codemeta.json
@@ -370,10 +370,10 @@
},
"SystemRequirements": "netcdf"
},
- "fileSize": "27935.52KB",
+ "fileSize": "27937.729KB",
"releaseNotes": "https://github.com/ropensci/chopin/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/chopin/blob/main/README.md",
- "contIntegration": ["https://github.com/ropensci/chopin/actions", "https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml"],
+ "contIntegration": "https://github.com/ropensci/chopin/actions/workflows/check-standard.yaml",
"developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html#stable",
"review": {
"@type": "Review",
diff --git a/man/chopin-package.Rd b/man/chopin-package.Rd
index a667492..0110160 100644
--- a/man/chopin-package.Rd
+++ b/man/chopin-package.Rd
@@ -12,7 +12,7 @@ geospatial data.
\section{Basic functionalities}{
\itemize{
-\item Distribute \code{terra}, \code{sf}, and \code{chopin} functions to parallel workers set by \code{future}
+\item Distribute \code{terra}, \code{sf}, and \code{chopin} functions to parallel workers set by \code{future} or \code{mirai}
\item Set parallelization strategies based on artificial grids, equal-size clusters, hierarchy, and multiple raster files
\item Convenience functions for raster-vector overlay and weighted summary from vector dataset
}
diff --git a/man/extract_at.Rd b/man/extract_at.Rd
index 9b7d70a..7ce2f34 100644
--- a/man/extract_at.Rd
+++ b/man/extract_at.Rd
@@ -17,7 +17,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -25,9 +24,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -37,7 +33,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -45,9 +40,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -57,7 +49,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -65,9 +56,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -77,7 +65,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -85,9 +72,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -97,7 +81,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -105,9 +88,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -117,7 +97,6 @@ extract_at(x, y, ...)
y = NULL,
id = NULL,
func = "mean",
- terra = FALSE,
extent = NULL,
radius = NULL,
out_class = "sf",
@@ -125,9 +104,6 @@ extract_at(x, y, ...)
kernel_func = stats::weighted.mean,
bandwidth = NULL,
max_cells = 3e+07,
- exact = TRUE,
- weights = TRUE,
- touches = FALSE,
.standalone = TRUE,
...
)
@@ -147,9 +123,6 @@ must have the same extent and resolution.}
Default is \code{"mean"} for all supported signatures in arguments
\code{x} and \code{y}.}
-\item{terra}{logical(1). If \code{TRUE}, use \code{terra::extract} instead of
-\code{exactextractr::exact_extract}.}
-
\item{extent}{numeric(4) or SpatExtent. Extent of clipping vector.
It only works with \code{points} of character(1) file path.}
@@ -168,12 +141,6 @@ Default is \code{\link[stats:weighted.mean]{stats::weighted.mean()}}}
\item{max_cells}{integer(1). Maximum number of cells in memory.}
-\item{exact}{passed to \code{terra::extract()} Default is TRUE.}
-
-\item{weights}{passed to \code{terra::extract()} Default is TRUE.}
-
-\item{touches}{passed to \code{terra::extract()} Default is FALSE.}
-
\item{.standalone}{logical(1). Default is \code{TRUE}, which means that
the function will be executed in a standalone mode.
When using this function in \verb{par_*} functions,
diff --git a/man/par_grid_mirai.Rd b/man/par_grid_mirai.Rd
index 878016b..b5799e0 100644
--- a/man/par_grid_mirai.Rd
+++ b/man/par_grid_mirai.Rd
@@ -86,6 +86,7 @@ res <-
radius = 5e3L,
id = "pid"
)
+mirai::daemons(0L)
}
\seealso{
\code{\link[mirai:daemons]{mirai::daemons}}, \code{\link[mirai:mirai_map]{mirai::mirai_map}}, \code{\link{par_convert_f}}
diff --git a/man/par_hierarchy_mirai.Rd b/man/par_hierarchy_mirai.Rd
index 8d002c8..bb6162d 100644
--- a/man/par_hierarchy_mirai.Rd
+++ b/man/par_hierarchy_mirai.Rd
@@ -135,6 +135,7 @@ res <-
func = "mean",
.debug = TRUE
)
+mirai::daemons(0L)
}
\seealso{
\code{\link[mirai:mirai_map]{mirai::mirai_map}}, \code{\link[mirai:daemons]{mirai::daemons}}, \code{\link{par_convert_f}}
diff --git a/man/par_multirasters_mirai.Rd b/man/par_multirasters_mirai.Rd
index 78bb5ce..37b32db 100644
--- a/man/par_multirasters_mirai.Rd
+++ b/man/par_multirasters_mirai.Rd
@@ -71,6 +71,7 @@ res <- par_multirasters_mirai(
id = "GEOID",
func = "mean"
)
+mirai::daemons(0L)
}
\seealso{
\code{\link[mirai:mirai]{mirai::mirai}}, \code{\link[mirai:mirai_map]{mirai::mirai_map}}, \code{\link[mirai:daemons]{mirai::daemons}},
diff --git a/tests/testthat/test-processing.R b/tests/testthat/test-processing.R
index 1f3f614..b6559bd 100644
--- a/tests/testthat/test-processing.R
+++ b/tests/testthat/test-processing.R
@@ -222,105 +222,6 @@ testthat::test_that("extract_at -- character-SpatVector inputs", {
})
-testthat::test_that("extract_at -- character-SpatVector inputs, terra mode", {
- withr::local_package("sf")
- withr::local_package("terra")
- withr::local_package("dplyr")
- withr::local_package("rlang")
- withr::local_options(list(sf_use_s2 = FALSE))
-
- nccnty <- system.file("shape/nc.shp", package = "sf")
- nccnty <- terra::vect(nccnty)
- ncelev <-
- system.file("extdata/nc_srtm15_otm.tif", package = "chopin")
-
- # test two modes
- ncexpoly <-
- chopin::extract_at(
- x = ncelev,
- y = nccnty,
- id = "FIPS",
- terra = TRUE,
- extent = NULL
- )
- testthat::expect_s4_class(ncexpoly, "SpatVector")
-
- testthat::expect_warning(
- testthat::expect_warning(
- testthat::expect_warning(
- testthat::expect_message(
- testthat::expect_message(
- ext_re <-
- chopin::extract_at(
- ncelev,
- nccnty,
- "FIPS",
- radius = 100,
- terra = TRUE,
- weights = FALSE,
- kernel = "epanechnikov",
- func = stats::weighted.mean,
- bandwidth = 1.25e4L
- )
- )
- )
- )
- )
- )
-})
-
-
-testthat::test_that("extract_at -- character-sf inputs, terra mode", {
- withr::local_package("sf")
- withr::local_package("terra")
- withr::local_package("dplyr")
- withr::local_package("rlang")
- withr::local_options(list(sf_use_s2 = FALSE))
-
- # starts from sf/stars
- ncp <- readRDS(system.file("extdata/nc_random_point.rds", package = "chopin"))
- ncp <- sf::st_transform(ncp, "EPSG:5070")
- nccnty <- system.file("shape/nc.shp", package = "sf")
- nccnty <- sf::st_read(nccnty)
- ncelev <-
- system.file("extdata/nc_srtm15_otm.tif", package = "chopin")
-
- # test two modes
- ncexpoly <-
- chopin::extract_at(
- ncelev,
- nccnty,
- "FIPS",
- terra = TRUE
- )
- testthat::expect_s4_class(ncexpoly, "SpatVector")
-
- testthat::expect_warning(
- testthat::expect_warning(
- testthat::expect_warning(
- testthat::expect_message(
- testthat::expect_message(
- extt <-
- chopin::extract_at(
- ncelev,
- nccnty,
- "FIPS",
- terra = TRUE,
- exact = TRUE,
- touches = FALSE,
- radius = 100,
- kernel = "epanechnikov",
- func = stats::weighted.mean,
- bandwidth = 1.25e4L
- )
- )
- )
- )
- )
- )
-})
-
-
## .extract_at tests ####
testthat::test_that(".extract_at + character inputs without kernel weighting", {
withr::local_package("sf")
diff --git a/tests/testthat/test-scale_process_mirai.R b/tests/testthat/test-scale_process_mirai.R
index f23f6bb..45b5ee9 100644
--- a/tests/testthat/test-scale_process_mirai.R
+++ b/tests/testthat/test-scale_process_mirai.R
@@ -230,7 +230,6 @@ testthat::test_that("par_hierarchy_mirai: define level by substring", {
})
-
testthat::test_that("generic function should be parallelized properly", {
withr::local_package("terra")
withr::local_package("sf")
@@ -244,6 +243,8 @@ testthat::test_that("generic function should be parallelized properly", {
)
)
+ mirai::daemons(4L, dispatcher = "process")
+
# main test
pnts <- readRDS(
system.file("extdata/nc_random_point.rds", package = "chopin")
@@ -277,7 +278,7 @@ testthat::test_that("generic function should be parallelized properly", {
),
"terra inputs detected in both x and y. Please replace x and y to file paths to proceed."
)
-
+ mirai::daemons(0L)
})