filter Stars object

Hi!

I am working with Spatiotemporal datasets and I am trying to figure out the way how to filter data. I am working with package Stars. My dataset looks like this :

poll <- read_stars("ecmwf/data/so2_co/pm_mar2006_0-6-12-18.nc")

stars object with 3 dimensions and 1 attribute
attribute(s), summary of first 1e+05 cells:
  so2 [kg/kg]       
 Min.   :2.067e-24  
 1st Qu.:2.110e-24  
 Median :2.140e-24  
 Mean   :2.207e-24  
 3rd Qu.:2.233e-24  
 Max.   :2.968e-24  
dimension(s):
     from  to         offset   delta                       refsys point values    
x       1 701         11.995    0.01 +proj=longlat +datum=WGS8...    NA   NULL [x]
y       1 311         51.505   -0.01 +proj=longlat +datum=WGS8...    NA   NULL [y]
time    1 124 2006-03-01 UTC 6 hours                      POSIXct    NA   NULL    

For every day I have two values in the data set (at 6am, at12pm). What i am trying to do is to filter data only for 6am.

I figured out one way, but it's not very handy, if I will have more data in the future.

poll %>% slice("time",seq(1,124,2))

Can anyone advice me easier way how to do it?
Thanks !

I would try to use filter()

I dont have your data.
Is there any easy to get public file thats similar enough to be relevant to the question ?

Here is how the use filter in the vignette

# install.packages("stars")
library(stars)
system.file("tif/L7_ETMs.tif", package = "stars") %>%
  read_stars -> x

stars:::filter.stars(x,
       band ==3 )
x

oh thanks for help, but it seems that filter() worked, I used
poll %>% filter(str_detect(time,'12:00:00'))

but again thanks a lot!
and stay safe!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.