为什么R不像gdalinfo那样提供信息?

时间:2012-10-12 13:46:45

标签: r netcdf

我在R中打开了一个netCDF文件并查看了标题信息。之后我使用gdalinfo查看同一文件的标题信息。

我发现gdalinfo(时间来源,单位等)显示的信息要多得多。是否有一个命令可以使用R来获取netCDF文件中变量的更多信息?

             f=open.ncdf("C:\\BR_Ban.nc")

              > f
            [1] "file C:\\GF_Guy_6Y.nc has 4 dimensions:"
              [1] "x   Size: 1"
              [1] "y   Size: 1"
              [1] "land   Size: 1"
           [1] "tstep   Size: 105120"
       [1] "double nav_lon[x,y]  Longname:Longitude Missval:1e+30"
       [1] "double nav_lat[x,y]  Longname:Latitude Missval:1e+30"
       [1] "float time[tstep]  Longname:Time axis Missval:1e+30"
     [1] "float timestp[tstep]  Longname:Time step axis Missval:1e+30"

Then read one variable

           A = get.var.ncdf(nc=f,varid="time",verbose=TRUE)
     [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=date"
     [1] "Variable named date found in file with varid= 7"
     [1] "vobjtovarid: returning with varid deduced from name; varid= 7"
    [1] "get.var.ncdf: ending up using varid= 7"
     [1] "ndims: 2"
  [1] "get.var.ncdf: varsize:"
    [1]     3 52560
     [1] "get.var.ncdf: start:"
     [1] 1 1
      [1] "get.var.ncdf: count:"
    [1]     3 52560
     [1] "get.var.ncdf: totvarsize: 157680"
     [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: 3    Length of data: 157680"     "count.nodegen: 52560    Length of data: 157680"
     [1] "get.var.ncdf: final dims of returned array:"
        [1]     3 52560

1 个答案:

答案 0 :(得分:4)

简而言之,因为gdalinfo是用于显示特定类型数据集的信息的程序,而R是用于分析各种数据集的语言。如果R每次导入数据集时都会向我发送这些信息,我很快就会疯了。

当然,这些信息可以在R中访问,您只需要求它。

class( f )
dim( f )
summary( f )
plot( f )