使用R下载NetCDF文件:手动工作,download.file产生错误 [英] Downloading NetCDF files with R: Manually works, download.file produces error

查看:123
本文介绍了使用R下载NetCDF文件:手动工作,download.file产生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从以下网站下载一组NetCDF文件:

I am trying to download a set of NetCDF files from: ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nwm/prod/nwm.20180425/medium_range/

当我手动下载文件时,连接没有问题,但是当我使用download.file并尝试连接时,出现以下错误: 断言失败!

When I manually download the files I have no issues connecting, but when I use download.file and attempt to connect I get the following error: Assertion failed!

程序:C:\ Program Files \ Rstudio \ bin \ rsession.exe 文件:nc4file.c,第2771行

Program: C:\Program Files\Rstudio\bin\rsession.exe File: nc4file.c, Line 2771

表达式:0

此应用程序已请求运行时以异常方式终止它. 请与应用程序的支持团队联系以获取更多信息.

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

我试图在没有R studio的情况下在R中运行代码,并得到相同的结果.

I have attempted to run the code in R without R studio and got the same result.

我的缩写代码如下:

library("ncdf4")
library("ncdf4.helpers")
download.file("ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nwm/prod/nwm.20180425/medium_range/nwm.t00z.medium_range.channel_rt.f006.conus.nc","c:/users/nt/desktop/nwm.t00z.medium_range.channel_rt.f006.conus.nc")
temp = nc_open("c:/users/nt/desktop/nwm.t00z.medium_range.channel_rt.f006.conus.nc")

推荐答案

在download.file参数中添加mode ='wb'对我来说解决了这个问题.下载PDF时遇到了同样的问题

Adding mode = 'wb' to the download.file arguments solves the issue for me. I've had the same problem when downloading PDFs

download.file("

download.file("ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nwm/prod/nwm.20180425/medium_range/nwm.t00z.medium_range.channel_rt.f006.conus.nc","C:/teste/teste.nc", mode = 'wb')

这篇关于使用R下载NetCDF文件:手动工作,download.file产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆