From 9e7b4c8a3cba47481f493f9b0ce879815ca80fb6 Mon Sep 17 00:00:00 2001 From: Eric Scott Date: Wed, 21 Aug 2024 14:10:06 -0700 Subject: [PATCH 1/5] change test to use raster with multiple layers --- tests/testthat/test-tar-terra-tiles.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-tar-terra-tiles.R b/tests/testthat/test-tar-terra-tiles.R index 03d2847..ae7d270 100644 --- a/tests/testthat/test-tar-terra-tiles.R +++ b/tests/testthat/test-tar-terra-tiles.R @@ -7,7 +7,8 @@ targets::tar_test("tar_terra_tiles() works", { list( tar_target( my_file, - system.file("ex/elev.tif", package="terra"), + # system.file("ex/elev.tif", package="terra"), + system.file("ex/logo.tif", package = "terra"), format = "file" ), tar_terra_rast( @@ -46,7 +47,8 @@ targets::tar_test("recombined tiles are equal to original", { list( tar_target( my_file, - system.file("ex/elev.tif", package="terra"), + # system.file("ex/elev.tif", package="terra"), + system.file("ex/logo.tif", package = "terra"), format = "file" ), tar_terra_rast( From 99f4b5177e3932921b4390ad73d9b6004367847d Mon Sep 17 00:00:00 2001 From: Eric Scott Date: Wed, 21 Aug 2024 14:13:36 -0700 Subject: [PATCH 2/5] use blocksize of first layer only, assumes it's the same for all layers of a raster --- R/tar_terra_tiles.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tar_terra_tiles.R b/R/tar_terra_tiles.R index 3892847..acb7e2b 100644 --- a/R/tar_terra_tiles.R +++ b/R/tar_terra_tiles.R @@ -286,7 +286,7 @@ tile_grid <- function(raster, ncol, nrow) { #' @export #' @rdname tile_helpers tile_blocksize <- function(raster) { - tile_ext <- terra::getTileExtents(raster, terra::fileBlocksize(raster)) + tile_ext <- terra::getTileExtents(raster, terra::fileBlocksize(raster)[1,]) n_tiles <- seq_len(nrow(tile_ext)) tile_list <- lapply( n_tiles, From 36df4f9973aa771e0bb4f696c393dce7f91eda89 Mon Sep 17 00:00:00 2001 From: Eric Scott Date: Wed, 21 Aug 2024 14:30:15 -0700 Subject: [PATCH 3/5] ignore dimnames checking for equality --- tests/testthat/test-tar-terra-tiles.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-tar-terra-tiles.R b/tests/testthat/test-tar-terra-tiles.R index ae7d270..cc58067 100644 --- a/tests/testthat/test-tar-terra-tiles.R +++ b/tests/testthat/test-tar-terra-tiles.R @@ -65,5 +65,7 @@ targets::tar_test("recombined tiles are equal to original", { targets::tar_make() targets::tar_load(c(my_map, rast_split)) recombined <- terra::merge(terra::sprc(rast_split)) - expect_equal(terra::values(my_map), terra::values(recombined)) + names(recombined) <- names(my_map) <- 1:3 #ignore dimnames because of bug #89 + expect_equal(terra::values(my_map), + terra::values(recombined)) }) From daa75c65cccb17ec645563cad04df6c55dd2c783 Mon Sep 17 00:00:00 2001 From: Eric Scott Date: Wed, 21 Aug 2024 15:47:50 -0700 Subject: [PATCH 4/5] different way of doing a multi-layer raster --- tests/testthat/test-tar-terra-tiles.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-tar-terra-tiles.R b/tests/testthat/test-tar-terra-tiles.R index cc58067..b220063 100644 --- a/tests/testthat/test-tar-terra-tiles.R +++ b/tests/testthat/test-tar-terra-tiles.R @@ -47,13 +47,13 @@ targets::tar_test("recombined tiles are equal to original", { list( tar_target( my_file, - # system.file("ex/elev.tif", package="terra"), - system.file("ex/logo.tif", package = "terra"), + system.file("ex/elev.tif", package = "terra"), format = "file" ), tar_terra_rast( my_map, - terra::rast(my_file) + #create multi-layer raster for testing + rast(c(my_file, my_file)) ), tar_terra_tiles( name = rast_split, @@ -65,7 +65,6 @@ targets::tar_test("recombined tiles are equal to original", { targets::tar_make() targets::tar_load(c(my_map, rast_split)) recombined <- terra::merge(terra::sprc(rast_split)) - names(recombined) <- names(my_map) <- 1:3 #ignore dimnames because of bug #89 expect_equal(terra::values(my_map), terra::values(recombined)) }) From eab4748deb921d83c772df3f0dd4cd9050677655 Mon Sep 17 00:00:00 2001 From: Eric Scott Date: Mon, 9 Sep 2024 11:28:59 -0700 Subject: [PATCH 5/5] add issue numbers to NEWS --- NEWS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4e7624e..2935ab3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,10 @@ # geotargets (development version) * Created `tar_stars()` and `tar_stars_proxy()` that create `stars` and `stars_proxy` objects, respectively. -* Created `tar_terra_tiles()`, a "target factory" for splitting a raster into multiple tiles with dynamic branching. -* Removes the `iteration` argument from all `tar_*()` functions. `iteration` now hard-coded as `"list"` since it is the only option that works (for now at least). -* Created two helper functions for use in `tar_terra_tiles()`: `tile_grid()` and `tile_blocksize()`. +* Created `tar_terra_tiles()`, a "target factory" for splitting a raster into multiple tiles with dynamic branching (#69). +* Created two helper functions for use in `tar_terra_tiles()`: `tile_grid()` and `tile_blocksize()` (#69, #87, #89). * Created utility function `set_window()` mostly for internal use within `tar_terra_tiles()`. +* Removes the `iteration` argument from all `tar_*()` functions. `iteration` now hard-coded as `"list"` since it is the only option that works (for now at least). * Added the `description` argument to all `tar_*()` functions which is passed to `tar_target()`. # geotargets 0.1.0 (14 May 2024)