3

I am trying to download a ncdf file using rCurl. Can anyone provide any advice on why this is not working?

require(RCurl)
require(ncdf4)

url <- "https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Seasonal_Climatology/4km/sst/"
filename <-"A20021722014263.L3m_SCSU_NSST_sst_4km.nc"

download.file(paste0(url, filename),destfile = paste0("~/Desktop/", filename), method="curl")

setwd("~/Desktop/")
files<-dir(pattern="*.nc")
f<-nc_open(files[1])

Error in R_nc4_open: NetCDF: Unknown file format

Error in nc_open(files[1]) :

Error in nc_open trying to open file A20021722014263.L3m_SCSU_NSST_sst_4km.nc

Vitali Avagyan
  • 1,193
  • 1
  • 7
  • 17
Megan
  • 195
  • 1
  • 14

1 Answers1

0

It appears that the file downloaded is an error file in XML format? If you open it in Notepad, you'll see it contains stuff like

Sorry, an error has occurred. Use the back button to return to the previous page or go to the Ocean Color Home Page

Are you sure that the filename you're wanting to download actually exists in that URL?

user2474226
  • 1,472
  • 1
  • 9
  • 9