4

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/

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!

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

Expression: 0

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

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

My abbreviated code is as followed:

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")
nick
  • 51
  • 5
  • 1
    possibly duplicate of https://stackoverflow.com/questions/20028061/how-to-download-file-from-internet-via-r – jwm Apr 26 '18 at 17:43

1 Answers1

9

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

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')

Luis
  • 629
  • 4
  • 9