2017-06-15 28 views
0

我正在下載並使用一些二進制衛星。 我有大約1400個網址下載並以矩陣格式處理它們。使用R錯誤下載二進制數據

這裏是我的網址: '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); 

回答

1

使用mode = 'wb'

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

感謝您的評論,似乎在下載二進制數據需要 '模式=「wb''。 詳情請參閱[本](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/download.file.html)。 –