Skip to content

Commit

Permalink
fixes #727
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Dec 12, 2024
1 parent 14ce3e1 commit 372ac63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 0.6-8

* fix `st_as_stars.im()`; #727 and #648, thanks to Barry Rowlingson

# version 0.6-7

* `st_extract()` fix if points coincide with boundary grid cell centers and bilinear interpolation is used; #720
Expand Down
8 changes: 7 additions & 1 deletion R/spatstat.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ as.owin.stars = function(W, ..., fatal) {
#' @export
st_as_stars.im = function(.x, ...) {
# see https://github.com/r-spatial/stars/issues/648
setNames(st_as_stars(as.data.frame(.x, ...)), "v")
#setNames(st_as_stars(as.data.frame(.x, ...)), "v")
d = dim(.x)
nd = create_dimensions(
list(x = create_dimension(1, d[2], .x$xrange[1], diff(.x$xrange)/d[2]),
y = create_dimension(1, d[1], .x$yrange[1], diff(.x$yrange)/d[1])),
get_raster(affine = c(0.0, 0.0), dimensions = c("x", "y"), curvilinear = FALSE))
st_stars(list(v = t(.x$v)), nd)
}

as.im.stars = function(X, ...) {
Expand Down

0 comments on commit 372ac63

Please sign in to comment.