r-spatial / stars

Spatiotemporal Arrays, Raster and Vector Data Cubes
https://r-spatial.github.io/stars/
Apache License 2.0
563 stars 94 forks source link

bug fix with aggregate #711

Open eborgnine opened 1 month ago

eborgnine commented 1 month ago

following up on

https://stackoverflow.com/questions/77311184/aggregating-r-stars-with-vector-valued-output/77447314#77447314

line 185 to 188 in aggregate.R, I think bind should be rbind in either case. the code below shows the 0% quantile is different from min, but when I change to rbind it's ok.

tif = system.file("tif/L7_ETMs.tif", package = "stars")
t1 = as.Date("2018-07-31")
x = read_stars(c(tif, tif, tif, tif), along = list(time = c(t1, t1+1, t1+2, t1+3)))[,1:30,1:30]

xmin = aggregate(x, by = '2 days', FUN = min) 
xrange = aggregate(x, by = '2 days', FUN = quantile) 

xDfmin = as.data.frame(xmin)
xDfrange = as.data.frame(xrange)

xDfmin[1:7,]
xDfrange[xDfrange$quantile=='0%',][1:7,]