diff --git a/R/processing.R b/R/processing.R index 3c967e2..c2d79c5 100644 --- a/R/processing.R +++ b/R/processing.R @@ -235,9 +235,12 @@ kernelfunction <- bind = TRUE, ID = TRUE ) - extracted$id_chopin <- y[[id]][extracted$ID] + + extracted[[id]] <- y[[id]][extracted$ID] + extracted$ID <- NULL names(extracted)[names(extracted) == "id_chopin"] <- id - names(extracted)[names(extracted) == "weight"] <- "coverage_fraction" + names(extracted)[names(extracted) %in% c("weight", "fraction")] <- + "coverage_fraction" } if (iskernel) { @@ -437,6 +440,7 @@ setMethod( y = NULL, id = NULL, func = "mean", + terra = FALSE, extent = NULL, radius = NULL, out_class = "sf", diff --git a/tests/testthat/test-processing.R b/tests/testthat/test-processing.R index ac566b1..60baeaa 100644 --- a/tests/testthat/test-processing.R +++ b/tests/testthat/test-processing.R @@ -222,7 +222,7 @@ testthat::test_that("extract_at -- character-SpatVector inputs", { }) -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") @@ -243,12 +243,13 @@ testthat::test_that("extract_at -- character-SpatVector inputs", { terra = TRUE, extent = NULL ) - testthat::expect_s3_class(ncexpoly, "data.frame") + testthat::expect_s4_class(ncexpoly, "SpatVector") testthat::expect_warning( testthat::expect_warning( testthat::expect_message( testthat::expect_message( + ext_re <- chopin::extract_at( ncelev, nccnty, @@ -268,7 +269,7 @@ testthat::test_that("extract_at -- character-SpatVector inputs", { }) -testthat::test_that("extract_at -- character-sf inputs", { +testthat::test_that("extract_at -- character-sf inputs, terra mode", { withr::local_package("sf") withr::local_package("terra") withr::local_package("dplyr") @@ -288,9 +289,10 @@ testthat::test_that("extract_at -- character-sf inputs", { chopin::extract_at( ncelev, nccnty, - "FIPS" + "FIPS", + terra = TRUE ) - testthat::expect_s3_class(ncexpoly, "data.frame") + testthat::expect_s4_class(ncexpoly, "SpatVector") testthat::expect_warning( testthat::expect_warning(