From 06e04a15b6eab5e3f8d786c799e04de8d8a52eff Mon Sep 17 00:00:00 2001 From: edzer Date: Wed, 20 Mar 2024 13:59:17 +0100 Subject: [PATCH] fixes https://github.com/r-spatial/gstat/issues/123 --- NEWS.md | 2 ++ R/sp.R | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5b891f1f3..addd8fdef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # version 0.6-5 +* fix `st_as_stars()` method for `Spatial` gridded objects; see https://github.com/r-spatial/gstat/issues/123 + * add `prcomp()` methods for `stars` and `stars_proxy` objects, working on attributes or last dimension * `st_rasterize()` with `align=TRUE` returns `NA` values where there are no data; #668 diff --git a/R/sp.R b/R/sp.R index d2295d331..705112d0d 100644 --- a/R/sp.R +++ b/R/sp.R @@ -48,7 +48,7 @@ st_as_stars.Spatial = function(.x, ...) { offset = gt$cellcentre.offset[1] - 0.5 * gt$cellsize[1], delta = gt$cellsize[1], refsys = st_crs(.x)) y = create_dimension(1, gt$cells.dim[2], - offset = gt$cellcentre.offset[2] + (gt$cells.dim[2] - 0.5) * gt$cellsize[1], + offset = gt$cellcentre.offset[2] + (gt$cells.dim[2] - 0.5) * gt$cellsize[2], delta = -gt$cellsize[2], refsys = st_crs(.x)) d = create_dimensions(list(x = x, y = y), raster = get_raster(dimensions = c("x", "y"))) lst = lapply(.x@data, function(x, dims) structure(x, dim = dims), dims = dim(d))