Skip to content

Commit

Permalink
skip cubble test; transform geometry array elements
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Jul 7, 2024
1 parent ffdad4c commit 464e224
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# version 0.6-6

* skip `cubble` tests for cubble version 0.3.1; https://github.com/huizezhang-sherry/cubble/issues/30

* `st_transform.stars` transforms geometries in array elements

* `mutate.stars` (and others) handle attribute names with spaces in them; #689

* `st_crop()` gains an argument `normalize`; when set to `TRUE` `st_normalize()` is called on the returned value; #685, #686
Expand Down
7 changes: 7 additions & 0 deletions R/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,18 @@ transform_curvilinear = function(x, crs, ...) {
#' plot(st_transform(st_as_sfc(x, as_points=FALSE), new), add = TRUE)
#' @seealso \link{st_warp}
#' @details For simple feature dimensions, \link[sf]{st_transform} is called, leading to lossless transformation. For gridded spatial data, a curvilinear grid with transformed grid cell (centers) is returned, which is also lossless. To convert this to a regular grid in the new \code{CRS}, use \link{st_warp} (which is in general lossy).
#'
#' If array values contain geometries and an array as a whole is of class `sfc` and
#' has a non-missing CRS, array geometries are also transformed.
#' @export
st_transform.stars = function(x, crs, ...) {

stopifnot(!is.na(crs), !is.na(st_crs(x)))

for (i in seq_along(x)) {
if (inherits(x[[i]], "sfc") && !is.na(st_crs(x[[i]]))) # array cells are geometries
x[[i]] = structure(st_transform(x[[i]], crs), dim = dim(x[[i]]))
}
if (has_sfc(x)) {
if (!inherits(crs, "crs") && !inherits(crs, "stars"))
crs = st_crs(crs) # needed for GDAL's transform of features
Expand Down
3 changes: 3 additions & 0 deletions man/st_transform.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-cubble.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ test_that("cubble", {
skip_if_not_installed("dplyr")
library(dplyr)
library(cubble)
skip_if(packageVersion("cubble") == "0.3.1") # https://github.com/huizezhang-sherry/cubble/issues/30
library(units)
tm = set_units(1:6, "days since 1985-01-01")
# l7 = st_as_stars(L7_ETMs) |> st_set_dimensions(3, values = Sys.time() + 1:6)
Expand Down

0 comments on commit 464e224

Please sign in to comment.