我有 netcdf 文件,我打开它并读取一个变量:
K=open.ncdf("C:\\hiba_history.nc")
Smonthly= get.var.ncdf(nc=K,varid="evap",verbose=TRUE)
[1] "vobjtodimname: is a character type varid. This file has 9 dims"
[1] "vobjtodimname: no cases found, returning FALSE"
[1] "get.var.ncdf: isdimvar: FALSE"
[1] "vobjtovarid: entering with varid=evap"
[1] "Variable named evap found in file with varid= 10"
[1] "vobjtovarid: returning with varid deduced from name; varid= 10"
[1] "get.var.ncdf: ending up using varid= 10"
[1] "ndims: 3"
[1] "get.var.ncdf: varsize:"
[1] 34 30 12
[1] "get.var.ncdf: start:"
[1] 1 1 1
[1] "get.var.ncdf: count:"
[1] 34 30 12
[1] "get.var.ncdf: totvarsize: 12240"
[1] "Getting var of type 3 (1=short, 2=int, 3=float, 4=double, 5=char, 6=byte)"
[1] "get.var.ncdf: C call returned 0"
[1] "count.nodegen: 34 Length of data: 12240" "count.nodegen: 30 Length of data: 12240"
[3] "count.nodegen: 12 Length of data: 12240"
[1] "get.var.ncdf: final dims of returned array:"
[1] 34 30 12
[1] "varid: 10"
正如你所看到的,这个变量有 30 像素和 34 行和 12 个波段(月)我想只写 12 的总和所以我最终得到一个文件来计算所有 12 个月的总和(每年)
apply(Smonthly, c(1,2), sum) -> Sannual
to.write = file(paste("C:\\annual.bin",sep=""),"wb")
writeBin(as.double(Sannual),to.write,size=4)
当我通过另一个程序打开文件时,我发现地图(文件)是颠倒的