2012-10-16 32 views
0

這三條線將NetCDF文件打開和讀取一個變量:爲什麼gdal給了我R的變量的不同最大值和最小值?

f=open.ncdf("C:\\BR_Ji1.nc") 
A = get.var.ncdf(nc=f,varid="date",verbose=TRUE) 
B = get.var.ncdf(nc=f,varid="GPP",verbose=TRUE) 
[1] "get.var.ncdf: entering. Here is varid:" 
[1] "GPP"     
[1] "checking to see if passed varid is actually a dimvar" 
[1] "entering vobjtodimname with varid= GPP" 
[1] "vobjtodimname: is a character type varid. This file has 6 dims" 
[1] "vobjtodimname: no cases found, returning FALSE" 
[1] "get.var.ncdf: isdimvar: FALSE" 
[1] "vobjtovarid: entering with varid=GPP" 
[1] "Variable named GPP found in file with varid= 17" 
[1] "vobjtovarid: returning with varid deduced from name; varid= 17" 
[1] "get.var.ncdf: ending up using varid= 17" 
[1] "ndims: 2"    
[1] "get.var.ncdf: varsize:" 
[1]  1 17520   
[1] "get.var.ncdf: start:" 
[1] 1 1      
[1] "get.var.ncdf: count:" 
[1]  1 17520    
[1] "get.var.ncdf: totvarsize: 17520" 
[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: 17520 Length of data: 17520" 
[1] "get.var.ncdf: final dims of returned array:" 
[1] 17520  
[1] "varid: 17" 
[1] "nc$varid2Rindex: 1" "nc$varid2Rindex: 2" "nc$varid2Rindex: 0" "nc$varid2Rindex: 0" "nc$varid2Rindex: 3" 
[6] "nc$varid2Rindex: 0" "nc$varid2Rindex: 4" "nc$varid2Rindex: 5" "nc$varid2Rindex: 6" "nc$varid2Rindex: 7" 
[11] "nc$varid2Rindex: 8" "nc$varid2Rindex: 9" "nc$varid2Rindex: 10" "nc$varid2Rindex: 11" "nc$varid2Rindex: 12" 
[16] "nc$varid2Rindex: 13" "nc$varid2Rindex: 14" "nc$varid2Rindex: 15" "nc$varid2Rindex: 16" "nc$varid2Rindex: 17" 
[21] "nc$varid2Rindex: 18" "nc$varid2Rindex: 19" "nc$varid2Rindex: 20" 
[1] "nc$varid2Rindex[varid]: 14" 
[1] "get.var.ncdf: setting missing values to NA" 
[1] "missval: -9999 tol: 0.09999" 
[1] "get.var.ncdf: implementing add_offset (FALSE) and scale_factor (FALSE)" 
[1] "var has NEITHER add_offset nor scale_factor" 
**K = get.var.ncdf(nc=f,varid="Qle",verbose=TRUE) 
write.table(t(rbind(A,B,K)),"C:\\Ji1-gpp-lat.txt")** 

當我看着提取的數據,我發現,我有非常小的負值。 然後我使用gdalinfo,發現最大值爲400,最小值爲0(這是正常的,這是值的樣子)。任何想法,爲什麼我錯誤地得到這個數字?

+1

你確定這不是一個顯示問題嗎?如果'gdalinfo'將數字格式設置爲整數,例如,小數量級的負數將顯示爲'0' –

+0

使用'-stats'重新執行'gdalinfo'以強制重新生成統計數據。 「R」報告是什麼?如果你知道Python/NumPy,你可以使用的另一個好工具是[netcdf4-python](http://code.google.com/p/netcdf4-python/)。 –

回答

0

看到這個問題:Does ComputeBandStats take nodata into account?。包含在文件元數據中的統計信息可能不是新鮮的或精確計算的。如果你想要精確的統計數據,你應該自己計算它們,或者確保使用近似值計算它們的標誌被設置爲False。

相關問題