[R] Problem downloading and opening netcdf file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Nov 17 16:03:09 CET 2010


On Wed, Nov 17, 2010 at 2:54 PM, D Kelly O'Day <koday at 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.

 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



More information about the R-help mailing list