canderson156
canderson156

Reputation: 1281

Reading in multiple rasters in terra package

I'm changing my spatial workflow to use the terra package instead of the raster package. With the raster package I used to read in multiple rasters directly into a stack.

filelist_temp <- list.files(datapath("Climate/World Clim 1 yr Monthly Weather/LCC June and July/June"), full.names = TRUE)
temp_rasters <- stack(filelist_temp)

Is there a simple way to do the same operation in terra?

This is what I came up with initially, but it doesn't work. I end up with a list of 25 spatRasters

temp_rasters <- c(lapply(filelist_temp, rast))

Upvotes: 10

Views: 5742

Answers (1)

canderson156
canderson156

Reputation: 1281

It's simpler than I realized

temp_rasters <- rast(filelist_temp)

Upvotes: 22

Related Questions