数据格式:1* 31* 10,共17个文件,存在D:\cyh\zpmi\路径下
setwd("D:/cyh/zpmi/")
path <- "D:/cyh/zpmi"
fileNames <- dir(path)
filePath <- sapply(fileNames, function(x){paste(path,x,sep='/')})
wind<-array(0,dim = c(1,31,10,17))
for (i in 1:17) {filename<-file(filePath[i],"rb")data<-readBin(filename,numeric(),1*31*10,size = 4)wind[,,,i]<-array(data=data,dim = c(1,31,10))close(filename)
}
write.filename = file("D:/cyh/zpmi/cyh.grd", "wb")
# 写为二进制文件
writeBin( as.vector(wind),write.filename,size = 4)
# 关闭文件
close(write.filename)
#######读取合并后文件#######
filename<-file("D:\\cyh\\zpmi\\cyh.grd","rb")
data<-readBin(filename,numeric(),1*31*10*17,size = 4)
bestdata<-array(data=data,dim = c(1,31,10,17))
close(filename)