Skip to content

Commit

Permalink
fiddle with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aariq committed Mar 20, 2024
1 parent e8b2b8b commit b279a01
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 56 deletions.
4 changes: 2 additions & 2 deletions R/geotargets-option.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#' @param gdal_raster_driver character, length 1; set the driver used for raster
#' data in target store (default: `"GTiff"`). Options for driver names can be
#' found here: <https://gdal.org/drivers/raster/index.html>
#' @param gdla_raster_creation_options character, length 1; set the GDAL creation options
#' @param gdal_raster_creation_options character; set the GDAL creation options
#' used when writing raster files to target store (default: `""`). You may
#' specify multiple values e.g. `c("COMPRESS=DEFLATE", "TFW=YES")`. Each GDAL
#' driver supports a unique set of creation options. For example, with the
#' default `"GTiff"` driver:
#' <https://gdal.org/drivers/raster/gtiff.html#creation-options>
#' @param gdal_vector_driver character, length 1; set the file type used for
#' vector data in target store (default: `"GeoJSON"`).
#' @param gdal_vector_creation_options character, length 1; set the GDAL layer creation
#' @param gdal_vector_creation_options character; set the GDAL layer creation
#' options used when writing vector files to target store (default:
#' `"ENCODING=UTF-8"`). You may specify multiple values e.g.
#' `c("WRITE_BBOX=YES", "COORDINATE_PRECISION=10")`. Each GDAL driver supports
Expand Down
15 changes: 4 additions & 11 deletions man/geotargets-options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 43 additions & 43 deletions tests/testthat/test-tar-terra.R
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# test_that() #Included to make RStudio recognize this file as a test
targets::tar_test("tar_terra_rast() works", {
geotargets::geotargets_option_set("raster_gdal_creation_options", c("COMPRESS=DEFLATE", "TFW=YES"))
targets::tar_script({
list(
geotargets::tar_terra_rast(
test_terra_rast,
terra::rast(system.file("ex/elev.tif", package = "terra"))
)
# geotargets::geotargets_option_set(gdal_raster_creation_options = c("COMPRESS=DEFLATE", "TFW=YES"))
targets::tar_script({
list(
geotargets::tar_terra_rast(
test_terra_rast,
terra::rast(system.file("ex/elev.tif", package = "terra"))
)
)
})
targets::tar_make()
x <- targets::tar_read(test_terra_rast)
expect_s4_class(x, "SpatRaster")
expect_snapshot(
x
)
})
targets::tar_make()
x <- targets::tar_read(test_terra_rast)
expect_s4_class(x, "SpatRaster")
expect_snapshot(
x
)
})

targets::tar_test("tar_terra_vect() works", {
targets::tar_script({
lux_area <- function(projection = "EPSG:4326") {
terra::project(
terra::vect(system.file("ex", "lux.shp",
package = "terra"
)),
projection
)
}
list(
geotargets::tar_terra_vect(
test_terra_vect,
lux_area()
),
geotargets::tar_terra_vect(
test_terra_vect_shz,
lux_area(),
filetype = "ESRI Shapefile"
)
)
})
targets::tar_make()
x <- targets::tar_read(test_terra_vect)
y <- targets::tar_read(test_terra_vect_shz)
expect_s4_class(x, "SpatVector")
expect_s4_class(y, "SpatVector")
expect_snapshot(x)
expect_snapshot(y)
expect_equal(terra::values(x), terra::values(y))
targets::tar_script({
lux_area <- function(projection = "EPSG:4326") {
terra::project(
terra::vect(system.file("ex", "lux.shp",
package = "terra"
)),
projection
)
}
list(
geotargets::tar_terra_vect(
test_terra_vect,
lux_area()
),
geotargets::tar_terra_vect(
test_terra_vect_shz,
lux_area(),
filetype = "ESRI Shapefile"
)
)
})
targets::tar_make()
x <- targets::tar_read(test_terra_vect)
y <- targets::tar_read(test_terra_vect_shz)
expect_s4_class(x, "SpatVector")
expect_s4_class(y, "SpatVector")
expect_snapshot(x)
expect_snapshot(y)
expect_equal(terra::values(x), terra::values(y))
})

0 comments on commit b279a01

Please sign in to comment.