From 0a321cc3b534bdf5d91f24f556d4b7250c744332 Mon Sep 17 00:00:00 2001 From: edzer Date: Tue, 27 Aug 2024 18:40:11 +0200 Subject: [PATCH] fixes #702 --- R/sf.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/sf.R b/R/sf.R index 99aff58c..67788c1e 100644 --- a/R/sf.R +++ b/R/sf.R @@ -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