I am very new to R, so please bear with my explanation. I have a raster list made up of 671 objects that I am hoping to clip to a shapefile.
At this link I explain how I uploaded the original .bin files and got help making a sub-list of just the March and April dates (I'm working with sea ice concentration rasters from NSIDC): Create a new list from a raster list in R
Now, I am hoping to crop that new sub-list. Here is what I have done (where "list_mar_apr" is the sub-list and "boundary" is the shapefile):
# Import and check shapefile
boundary <- readOGR("file_folder/shapefile.shp")
plot(boundary)
# Crop subset to the shapefile
list_mar_apr_crop <- crop(list_mar_apr, boundary)
I keep getting an error message that reads:
unable to find an inherited method for function 'crop' for signature 'list'.
crop(list_mar_apr[[1]], boundary)
do the right thing for the first raster? In that case you need to loop over the rasters in the list withlapply
. If all the rasters are the same size and extent then alternatively you could make a multi-bandstack
orbrick
instead of using a list.