diff --git a/NEWS.md b/NEWS.md index 5b891f1f..addd8fde 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 d2295d33..705112d0 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))