我有多个每日降水栅格,并希望按相同程度进行修剪。我已经尝试了下面的代码,但没有结果。我想念什么吗?
library(raster)
shapefile <- "F:/Data/Shapefile/Azraq_Basin"
# Reading the raster I want to crop
raster <- raster("F:/Data/CHIRPSv2")
# Getting the spatial extent of the shapefile
e <- extent(shapefile)
# Cropping the raster to the shapefile spatial extent
raster.crop <- crop(raster, e, snap="out")
crop <- setValues(raster.crop, NA)
shp.r <- rasterize(shp, crop)
raster.masked <- mask(x=raster.crop, mask=shapefile.r)
output <- "F:/Data/new"
我希望它可以将每个全局每日数据裁剪到shapefile的程度,并将输出保存在指定目录中。