在R中使用NCEP/NOAA.bin文件

在R中使用NCEP/NOAA.bin文件,r,R,我正在尝试在PC上使用R版本2.14.0从NOAA()读取.bin文件。 当我使用函数readBin读取文件时,值非常高(从1e16到9e16),但不应高于330 我编写了下面的代码来下载包含信息的.zip文件(注意:编号20130422是相关的) 截止日期,因此可能会有另一个日期) file.name我不确定您是否设法解决了这个问题,但我在NOAA数据方面遇到了类似的问题。我的数据是从lat-40到40和lon-20到55,间距为0.1度。因此它有751列和801行。尽管NOAA说是“小”en

我正在尝试在PC上使用R版本2.14.0从NOAA()读取.bin文件。 当我使用函数readBin读取文件时,值非常高(从1e16到9e16),但不应高于330

我编写了下面的代码来下载包含信息的.zip文件(注意:编号20130422是相关的) 截止日期,因此可能会有另一个日期)


file.name我不确定您是否设法解决了这个问题,但我在NOAA数据方面遇到了类似的问题。我的数据是从lat-40到40和lon-20到55,间距为0.1度。因此它有751列和801行。尽管NOAA说是“小”endian,但我发现“大”endian为我的机器工作。此外,我还必须翻转数据,使矩阵与R读取数据和绘制数据的方式相匹配。最后,我覆盖了一张非洲地图,因为我的数据是非洲的降雨数据。我还安装了“光栅”、“地图”和“地图数据”软件包

以下是我的解决方案:

infile <- file("clim.bin.0101", "rb")
outfile <- matrix(readBin(infile, "numeric", 
                      n = 751 * 801, size = 4, 
                      endian = "big"), ncol= 751, 
              nrow = 801, byrow = TRUE);    
close(infile)
tran_outfile <- apply(outfile,2,rev) #flips the matirx so data is in correct order 
r = raster(tran_outfile)
extent(r) = extent(c(xmn=-20,xmx=55,ymn=-40,ymx=40))
plot(r)
plot(wrld_simpl, add=T)

infle我会找到数据提供者并找出文件的结构,这样您就可以正确地指定它了。例如,您如何知道它是720x720?
    to.read <- 'tmax.20130422.daily.latlon.bin' 
    bin <- readBin(to.read, what = 'numeric',n = 720*720,endian='little') 
infile <- file("clim.bin.0101", "rb")
outfile <- matrix(readBin(infile, "numeric", 
                      n = 751 * 801, size = 4, 
                      endian = "big"), ncol= 751, 
              nrow = 801, byrow = TRUE);    
close(infile)
tran_outfile <- apply(outfile,2,rev) #flips the matirx so data is in correct order 
r = raster(tran_outfile)
extent(r) = extent(c(xmn=-20,xmx=55,ymn=-40,ymx=40))
plot(r)
plot(wrld_simpl, add=T)