TransWikia.com

stars package in R. How to add time dimension in a stars object?

Geographic Information Systems Asked on October 4, 2021

I have a raster stack (my_stack) and I converted it into a stars object:

mystar <- st_as_stars(my_stack)

That results in:

stars object with 3 dimensions and 1 attribute
attribute(s), summary of first 1e+05 cells:
    layer.1        
 Min.   :  0.0000  
 1st Qu.:  0.0000  
 Median :  0.0000  
 Mean   :  0.7897  
 3rd Qu.:  0.0000  
 Max.   :686.6100  
dimension(s):
     from  to  offset delta                       refsys point               values    
x       1 904  104010  1000 +proj=tmerc +lat_0=0 +lon...    NA                 NULL [x]
y       1 773 4623806 -1000 +proj=tmerc +lat_0=0 +lon...    NA                 NULL [y]
band    1  67      NA    NA                           NA    NA layer.1,...,layer.67    

I also have a vector with Date objects.
How could I add this vector as time dimension in mystar object?

One Answer

This should work:

mystar = st_set_dimensions(mystar, 3, values = dates, names = "date")

where dates is the Date vector.

Answered by Michael Dorman on October 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP