Skip to content

Commit

Permalink
fixes #702
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Aug 27, 2024
1 parent b4e0501 commit 0a321cc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ st_as_sf.stars = function(x, ..., as_points = FALSE, merge = FALSE, na.rm = TRUE
names(df) = names(dfs)
else { # another exception... time as second dimension
e = expand_dimensions(x)
if (length(e[-ix]) == 1 && inherits(e[-ix][[1]], c("Date", "POSIXt", "PCICt")))
names(df) = as.character(e[-ix][[1]])
if (length(e[-ix]) == 1 && inherits(e[-ix][[1]], c("Date", "POSIXt", "PCICt"))) {
names(df) = if (length(nc) > 1)
do.call(paste, rev(expand.grid(e[-ix][[1]], names(x))))
else
as.character(e[-ix][[1]])
}
}

df[[ names(st_dimensions(x))[ ix[1] ] ]] = sfc # keep dimension name
Expand Down

0 comments on commit 0a321cc

Please sign in to comment.