I am having 20 raster layers and 1 shapefile. I would like to:
crop and mask each raster iteratively (i.e., first crop and mask the first raster, then the second and so on)
save each cropped raster with the same name as its original into a subfolder of the working directory.
I can do this for every raster (manually, one-by-one) but I would like to automate the process. My raster layers do not have the same extent, that's why I want to crop and mask each one by one (also they are large in size (mb)). Here is the code for doing this in a one-by-one manner:
Just to mention that I had to create the subfolder in order for your code to run without an error. Maybe I should have mentioned that in the post that I would like the folder to be created inside the code but still, your code runs perfectly fine.