【问题标题】:Downloading data from the internet using R使用 R 从 Internet 下载数据
【发布时间】:2018-08-10 14:24:42
【问题描述】:

我正在尝试从以下网站下载数据

https://gimms.gsfc.nasa.gov/MODIS/std/GMOD09Q1/tif/NDVI/

本网站有来自 MODIS 传感器的 NDVI 数据。这些文件夹是根据我需要下载的年份和日期排列的。

作为测试,我尝试只下载一个数据

URL <- "https://gimms.gsfc.nasa.gov/MODIS/std/GMOD09Q1/tif/NDVI/2010/001/GMOD09Q1.A2010001.08d.latlon.x39y03.6v1.NDVI.tif.gz"

library(RCurl)

x <- getURL(URL, ssl.verifypeer = FALSE)

我收到这个错误

Error in function (type, msg, asError = TRUE)  : 
Unknown SSL protocol error in connection to 
gimms.gsfc.nasa.gov:443

然后我尝试了这个:

download.file(url = URL,
          destfile = 'localfile.gz', method='curl')

Error in download.file(url = URL, destfile = "localfile.gz", method = "curl") : 
'curl' call had nonzero exit status

谁能告诉我我做错了什么。

谢谢

【问题讨论】:

  • 尝试将 URL 更改为 http://....(不是 https)?祝你好运。

标签: r curl rcurl


【解决方案1】:

要读取内存,请尝试:

library("curl")
x <- curl::curl_fetch_memory("https://gimms.gsfc.nasa.gov/MODIS/std/GMOD09Q1/tif/NDVI/2010/001/GMOD09Q1.A2010001.08d.latlon.x39y03.6v1.NDVI.tif.gz")

或者,在本地保存:

f <- "local.tif.gz"
curl::curl_fetch_disk("https://gimms.gsfc.nasa.gov/MODIS/std/GMOD09Q1/tif/NDVI/2010/001/GMOD09Q1.A2010001.08d.latlon.x39y03.6v1.NDVI.tif.gz", path = f)

【讨论】:

    猜你喜欢
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多