【问题标题】:downloading binary data using R error使用R错误下载二进制数据
【发布时间】:2017-06-15 13:38:11
【问题描述】:

我正在下载并使用一些二进制卫星。 我有大约 1400 个 url 以矩阵格式下载和处理它们。

这是我的网址: 'nasanex.s3.amazonaws.com/AVHRR/GIMMS/FPAR3G/AVHRRBUVI01.1981auga.abf'

案例 1: 当我下载(通过我的浏览器)和处理(在 Matlab 中)文件时,我的矩阵输出似乎是正确的。 Correct Output

案例 2: 当我下载(通过 R)和处理(在 Matlab 中)文件时,我的矩阵输出似乎不正确。 Incorrect Output

我想知道为什么会这样。 我正在分享我用于下载的“R”:

download.file(myurl_1, destfile = myfile_1, mode ='w')

为了读取数据,我使用了简单的“matlab”代码。

myfile = allfiles(1,1:end);
fid = fopen(char(myfile), 'r');
data = fread(fid,[2160,4320],'uint8',0,'ieee-be');
data(data == 250)= nan;
fclose(fid);

【问题讨论】:

    标签: r matlab matrix


    【解决方案1】:

    使用mode = 'wb'

    download.file(myurl_1, destfile = myfile_1, mode ='wb')
    

    【讨论】:

    • 感谢您的评论,下载二进制数据似乎需要mode = 'wb'。详情请参阅this
    猜你喜欢
    • 2014-11-21
    • 2011-11-07
    • 2020-07-31
    • 1970-01-01
    • 2021-07-01
    • 2011-10-27
    • 2016-02-18
    • 2012-10-06
    • 1970-01-01
    相关资源
    最近更新 更多