rterra

How to assemble large data cube for efficient handling with`terra`?


My raster files are organized hierarchically in folders according to simulation, variable and time span. How would an adept terra user assemble and load the data cube for efficient posterior data analysis, i.e. flexible sub-setting across different dimensions?

Currently I parse the folder structure and store all attributes in a data frame, import the respective raster as a list into an additional column, then collect different layers as needed into a larger raster. However this process is a bit cumbersome so I wondered, how the long-time users would go about this.


Solution

  • I would select the files I need by subsetting the data.frame d according to some criterion and do

    x <- rast(d$filename)
    

    I would not add the any SpatRasters to a data.frame or list.