I have about 50.000 small glacier rasters (rectangular) that need to be clipped to the glaciers' extents. I also have the corresponding glacier polygons stored in a large SpatialPolygonsDataFrame. I want to use parallel computing or else it would take forever, I think. For previous tasks I've successfully used the ```mcmapply```function, but I am open for other approaches. My code so far is: ``` filenames <- list.files("/.../RGI60-13_reproj/", pattern="*.tif", full.names=F) filelocations <- list.files("/.../RGI60-13_reproj/", pattern="*.tif", full.names=T) glaciers <- readOGR("/.../13_rgi60_CentralAsia.shp",verbose=TRUE) fun_clip <- function(filelocations, filenames, glaciers){ r <- raster(filelocations) r <- crop(r,glaciers) # corresponding position in the dataframe writeRaster(r, paste0("/.../RGI60-13_crop/",filenames)) } mcmapply(fun_proj, filelocations, filenames, mc.cores = 50) ``` How can I give the ```crop```-function the right iterative arguments? ```filelocation```is of the same length as ```glaciers```, so in a ```for-loop```I would use something like ```r <- crop(r,glaciers[1])```, but how do I pass the iteration in my kind of function? What would be the way to introduce the ```i```, so to speak?