【发布时间】:2021-02-12 15:39:29
【问题描述】:
我正在尝试在 for 循环中迭代多个栅格 (+500),但我遇到了一些问题。
首先我想将它们从 CRS EPSG:4326 重新投影到 CRS EPSG:32614,然后使用具有较小分辨率和扩展名的掩码光栅重新采样它们,最后为工作目录中的每个光栅编写一个结果光栅,但我一直收到以下有关 CRS 参数的错误消息:
Error in CRS(x) : PROJ4 argument-value pairs must begin with +: E:\Proyecto PM2.5\2_PM_2.5_Processing\Test/AOD_MOD_CDTDB_April_2016.tif
我在这里查看了多个帖子,但我无法解决这个问题。以下是我的代码,任何帮助都将非常感谢这个 R 初学者
#find all tifs in your directory
dir<-"E:\\Proyecto PM2.5\\2_PM_2.5_Processing\\Test"
#get a list of all files with .tif in the name in the directory
files<-list.files(path=dir, pattern='.tif', full.names = TRUE)
#raster with the expected characteristics: extension, cellsize, number of pixels
r_ref <- raster("E:\\Proyecto PM2.5\\3_PM_2.5_Entrega\\temporal\\Raster_C.tif")
for (file in files){
name <- file
projectRaster(name,crs="+init=epsg:32614")
resample(file,r_ref,method="ngb")
savename<-sub("ZMVM",name,basename(file))
writeRaster(r,file=savename,)
}
【问题讨论】: