0
我想寫與尺寸創建的NetCDF [R
73 (LON) x 36 (LAT) x 12 (TIME)
從12點矩陣與創建M3D三維矩陣netCDF文件暗淡
73 (LON) x 36 (LAT)
這裏是我的代碼
#Setting dimensions
space <- 5
Longvector = seq(-180, 180, by = space)
Latvector = seq(-90, 90, by = space)
dimMATR <- 73
dimMATC <- 36
dimX <- dim.def.ncdf("Long", "degrees", Longvector)
dimY <- dim.def.ncdf("LAT", "degrees", Latvector)
dimT <- dim.def.ncdf("Time", "days", 1:12, unlim = FALSE)
#Create 3d Matrix
m3d <- array(0, dim = c(dimMATR,dimMATC,12))
for (i in 1:12){
m <- as.matrix(do.call(rbind,myfilesContent[i]))
m3d[,,i]<-t(m)
remove(m)
}
#Create NetCDF
mv <- -9999 # missing value to use
L <- prod(dimMATR,dimMATC,12)
var3d <- var.def.ncdf("monthlyav_sst", "units", list(dimX,dimY,dimT), mv,prec="double")
nc <- create.ncdf("monthlyav_sst.nc", var3d)
put.var.ncdf(nc, var3d, m3d, start = c(1, 1, 1), count = c(1, 1, L))
close.ncdf(nc)
無論如何,我得到這個錯誤的輸出
Error in R_nc_put_vara_double: NetCDF: Start+count exceeds dimension bound
Error in put.var.ncdf(nc, var3d, m3d, start = c(1, 1, 1), count = c(1, :
C function R_nc_put_var_double returned error
你可以試試'數= C(-1,-1,-1)'和計數應自動確定。順便說一句:你的意思是'Longvector = seq(-180,180,by = space)'? – sgibb