-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf
Of Alexandre VILLERS
Sent: Wednesday, July 15, 2009 10:03 AM
To: Aide R SIG GEO
Subject: [R-sig-Geo] still struggling with FTP download on MODIS
Dear all,
I'm still not sure that this list is the right place for that. So if
those questions bother you, please give me the name of the list I should
contact.
Here a version of the script I'm using to download MODIS data from NSIDC
(weekly snow cover)
Tsnow <-
"ftp://anonymous:test at n4ftl01u.ecs.nasa.gov/SAN/MOST/MOD10A2.005/"
###server of NSIDC with directories / id and password
myfolder<-paste(tempdir(),"\\" , sep="") #the folder to download data
#####-getting the list of the folders in Tsnow (thanks to Barry Rowlingson)
resp <-getURL(Tsnow)
items <- strsplit(resp,"\r\n")[[1]]
folderLines <- items[substr(items,1,1)=='d']
lastBit <- function(x){x[length(x)]}
dates <- unlist(lapply(strsplit(folderLines," "),lastBit))
datesK<-data.frame(dates=dates, keep=rep(NA,length(dates)))
##### select months for which I want the data
months<-c("01","02","03","04","05","06","10", "11", "12") #months for
which I want the data
for (i in months){ #loop to keep only the dates I'm interested in
garde<-grep(datesK$dates, pattern=paste(".",i,".", sep=""))
datesK$keep[garde]<-1
}
datesK<-subset(datesK, datesK$keep==1) # keep the dates of interest
for (i in 1:length(datesK[,1])){ ## loop to download the tiles of
interest
getlist1 <- strsplit(getURL(paste(Tsnow, datesK[i,][[1]], "/",
sep=""),.opts=curlOptions(ftplistonly=TRUE)), "\r\n")[[1]] #get the
files in the folder i
BLOCKtemp <- getlist1[grep(getlist1,
pattern="MOD10A2.********.h18v04.005.*************.hdf")[1]] #select the
tile of interest (in my case h18v04.005)
download.file(paste(Tsnow, datesK[i,][[1]], "/",
BLOCKtemp,sep=""), destfile=paste(myfolder, BLOCKtemp, sep=""),
mode='wb', method='wget') #download the tile
}
So here is my problem. I can't get into some specifc folders and receive
the error message.
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
server did not report OK, got 550