J'ai fichier netcdf je l'ai ouvert et lu une variable:Comment écrire plusieurs bandes de netcdf dans un fichier binaire?
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"
Comme vous pouvez le voir, cette variable a 30 pixels et 34 lignes et 12 bandes (mois) Je voudrais juste écrire la somme du 12 donc je suis finalement un dossier qui calculent la somme de tous les 12 mois (à annuelle)
apply(Smonthly, c(1,2), sum) -> Sannual
to.write = file(paste("C:\\annual.bin",sep=""),"wb")
writeBin(as.double(Sannual),to.write,size=4)
Quand j'Opend le fichier à travers un autre programme, je trouve que la carte (fichier) était à l'envers vers le bas
S'il vous plaît spécifier ce qui ne fonctionne pas, où vous ne parvenez pas à calculer la somme, ou incapable de vider le fichier? Veuillez rendre votre problème reproductible ... –
FYI 'paste (" C: \\ annual.bin ", sep =" ")' est inutile, écrivez juste '" C: \\ annual.bin "'. – plannapus