Stack RasterDataset by date

raster

#1

Good morning,

I would like to stack a raster dataset taking into account the number of days between images. Sometimes the number of dates between observations are 8, 16 or 365 days. Is there any function to do it automatically?

The code that I have right now is as follows:

setwd("C:\\NDVI_prueba")
rlist=list.files(pattern=".tif$", full.names=T)
rasters=stack(rlist)
rasters

I guess that this code does not count the separation between days and has the same interval for all the images...?

The name of the files is: NDVI.2000_01_01_NDVI is it correct or should I give a special name to be able to determine the date in each image?


#2

Are the files like

  • NDVI.2000_01_01_NDVI.tif
  • NDVI.2000_01_09_NDVI.tif
  • NDVI.2000_01_25_NDVI.tif
  • NDVI.2001_01_25_NDVI.tif

?
If that is the case you could extract the date component, i.e. 2001_01_25, transform it in a proper data using for example lubridate and group the files according to some login before stacking them...


#3

Thank you for your help. Could you show me an example please? I do not really know how to transform the data and stack it later.