Skip to content

Commit

Permalink
address #659
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Aug 27, 2024
1 parent 28f7937 commit 250ede1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions R/dimensions.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ st_dimensions.default = function(.x, ..., .raster, affine = c(0, 0),
#' # set bandwidth intervals:
#' (x3 = st_set_dimensions(x, "band", values = make_intervals(bw), names = "bandwidth"))
st_set_dimensions = function(.x, which, values = NULL, point = NULL, names = NULL, xy, ...) {
if (inherits(.x, "mdim"))
stop("for mdim objects, use st_set_dimensions() after st_as_stars()")
d = st_dimensions(.x)
if (!missing(which) && is.character(which))
which = match(which, base::names(d))
Expand Down
2 changes: 2 additions & 0 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ st_extract.stars = function(x, at, ..., bilinear = FALSE, time_column =
x = st_as_stars_proxy(x)

min_dist = NULL
if (inherits(x, "mdim"))
x = st_as_stars(x) # realize
m = if (inherits(x, "stars_proxy")) {
try_result = try(x0 <- st_as_stars(x, downsample = dim(x)/2), silent = TRUE)
lapply(x, function(y) do.call(abind, lapply(get_names(y),
Expand Down
2 changes: 1 addition & 1 deletion R/mdim.R
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ st_as_stars.mdim = function(.x, ..., downsample = 0, debug = FALSE,
ds[1:2] = downsample
downsample = ds
}
step = rep_len(downsample, length(dim(.x))) + 1
step = rep_len(round(downsample), length(dim(.x))) + 1
offset = sapply(d, function(x) x$from) - 1
count = (sapply(d, function(x) x$to) - offset) %/% step
if (debug)
Expand Down

0 comments on commit 250ede1

Please sign in to comment.