On Wed, 17 Nov 2010, Barry Rowlingson wrote:

On Wed, Nov 17, 2010 at 2:54 PM, D Kelly O'Day <ko...@processtrends.com> wrote:

I am trying to download and open an on-line netcdf file.

I'm using Windows XP and R 2.11.1

Here's my script

 library(ncdf)
 link <-
"http://ibis.grdl.noaa.gov/SAT/SeaLevelRise/slr/slr_sla_gbl_free_all_66.nc";
 dest <-  "C:/temp/slr_sla_gbl_free_all_66.nc"
 download.file(url=link,destfile=dest)
 nc1 <- open.ncdf(dest)

The file appears in my C:/temp directory, however I can not open() it, I get
this error message:

  nc1 <- open.ncdf(dest)
Error in open.ncdf(dest) :
 Error in open.ncdf trying to open file C:/temp/slr_sla_gbl_free_all_66.nc


I can manually download and save the netcdf file and then open it. I'd like
to be able to automate the download and open process within my script.

Works for me. When you get the file with download.file is it
identical to when you download it from a web browser? I can only think
its getting corrupted, or perhaps your download.file isn't going
through a proxy or something and you're actually saving a proxy error
message file.

(S)he is using Windows and forgot mode="wb": AFAIK netcdf files are binary files.

Check the length of the saved file: file.info(dest) should help -
check the 'size' is what you expect. I get 17004 for that example.

Barry

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to