[R-sig-Geo] Cropping Large RasterStack
Łukasz Pawlik
|ukp@w||k @end|ng |rom gm@||@com
Thu Jul 15 10:08:59 CEST 2021
Hi,
I normally use this simple function and for loop to automate the process.
get_file <- function(x){
mask1 <- st_read('XXXXXXXXXXXXXXXXX.shp')
raster1 <- terra::rast(paste0('file_path',
list_of_files[x],'.tif'))
terra::crop(raster1, mask1,
filename=paste0('file_path',
list_of_files_new[x],'.tif'))
unlink(paste0('file_path',
list_of_files_new[x],'.tif'))
}
get_chelsa(x)
numbers <- 1:420
for(i in numbers){
get_chelsa(i)
}
If files are large, I use a computer cluster, for instance,
http://www.plgrid.pl/en.
Hope this helps.
Best,
Lukasz
czw., 15 lip 2021 o 09:56 Jesús Rojo <jru85yebe using hotmail.com> napisał(a):
> Hello everyone
> I have a Large RasterStack (8501485725 elements, 336.8 Mb) compounded by
> 23750 raster layers (0.1 degree of resolution)
> I would like to do a crop based on an extent
>
> 'tmax <- crop(tmax, extent(0, 20, 40, 55))’
>
> It seems to be very time-consuming, and even it seems that my pc is not
> able to crop after a long time
> Do you know another efficient way to do this task without parallelizing?
> I think that I did this task with large stacks in the past with ‘crop’ and
> it run well, but now I do not know if it is possible
> Thanks for your help
> Kind regards
>
> Jesús Rojo
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
WWW: https://www.biomorpho.us.edu.pl/
ResearchGate: https://www.researchgate.net/profile/ukasz_Pawlik
Twitter: @BMGResearchTea1
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list