【问题标题】:why gdal gave me different max and min values of a variable from R?为什么gdal给了我来自R的变量的不同最大值和最小值?
【发布时间】:2012-10-06 07:31:17
【问题描述】:

这三行将打开并从 netcdf 文件中读取一个变量:

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(这是正常的,这就是值的样子)。任何想法为什么我得到错误的号码?

【问题讨论】:

  • 您确定这不是显示问题吗?例如,如果gdalinfo 将数字格式化为整数,那么微小的负数将显示为0
  • -stats 重新执行gdalinfo 以强制重新生成统计信息。 R 报告了什么?如果您了解 Python/NumPy,您可以使用的另一个好工具是 netcdf4-python

标签: r gdal netcdf rgdal


【解决方案1】:

看到这个问题:Does ComputeBandStats take nodata into account?。文件元数据中包含的统计数据可能不是新鲜的或精确计算的。如果您想要准确的统计数据,您应该自己计算它们,或者确保使用近似值计算它们的标志设置为 False。

【讨论】:

    猜你喜欢
    • 2015-05-19
    • 2020-10-03
    • 2020-09-06
    • 2022-09-27
    • 2012-08-09
    • 1970-01-01
    • 2021-11-04
    • 2021-07-06
    • 1970-01-01
    相关资源
    最近更新 更多