I am working with ESRI's Sentinel landcover data at 10meter resoltuion: https://livingatlas.arcgis.com/landcoverexplorer/#mapCenter=-83.21%2C34.332%2C4&mode=step&timeExtent=2017%2C2021&year=2017&downloadMode=true
I'm working with these data in R with the package terra
My project extent is the entire continental USA. I have binned the USA into equal area hexagonal bins
(projection: proj<-"+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs")
of varying spatial scales and I need to intersect the landcover data with these bins (a polygon file) and extract landcover information (relative areas etc.) for each bin. Because the bins can overlap with two or more images depending on its position I am currently reprojecting all the sentinel images to the same equal area projection as my bins but this is taking a very long time given the resolution of the data. Because of my project's focus (insects) the higher the resolution of the images, the better. Additionally, because of the time-varying aspect of my data I need to do this for every year from 2017-2022.
This is just an example code with terra but this is where I am hitting a slowdown because one run of reprojecting 37 rasters takes anywhere from 12-15 hours on my computer:
library(terra)
#get directory
raster_dir<-"/Users/leoohyama/Downloads/USA_Sentinel_2022/"
file_Rast<-list.files(raster_dir)
setwd(raster_dir)
#set projection
proj<-"+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs"
#lapply to reproject all raster images and write them to disk
lapply(file_Rast, function(x){
rast1<-terra::rast(x)
ras1p<-terra::project(rast1, proj)
terra::writeRaster(ras1p, paste(x, "projected.tif", sep = "_"))
rm(rast1)
rm(ras1p)
})
Once I reproject the images per year I plan to group then in virtual rasters and mosaic them. Then I plan to run the intersections with my hex bins on the mosaic-ed raster. But I also know this will take forever (or I may run out of memory in terms of RAM).
However one other issue I am also realizing is that the reprojected rasters for just one year take up close to 40-50 Gigabytes of space. So the issue of memory usage is also apparent.
Is there a more efficient way to do this?