我有一些ASCII格式的栅格文件,我想根据一个ASCII格式的栅格进行调整。我编写了代码,但是存在一些我无法解决的问题。 请指导我该怎么做。 这是我的代码:
# list all files in reclass1 folder
flname1 <- list.files(path = 'C:/somayeh/resample test', pattern = '.asc$',
full.names=FALSE)
nfile1 <- list(flname1)
# list all files in reclass2 folder
flname2 <- list.files(path = 'C:/somayeh/resample test/resample', pattern =
'.asc$', full.names=FALSE)
nfile2 <- list(flname2)
# Resample reclass1 image based on reclass2 image
for (i in 1:nfile1) {
r1<-raster(flname1[[i]])
r2<-raster(flname2[[i]])
rs<-resample(r1,r2, method='bilinear') # you can choose your own method
}
# Save the ouput
write.Raster(rs, paste0('C:/somayeh/resample test',i,'.img'), overwrite=T)
错误是:
Error in 1:nfile1 : NA/NaN argument