[R] Problem with Downloading TRMM

Eliza Botto eliza_botto at outlook.com
Thu Nov 12 06:25:06 CET 2015


Dear Users of R,
I have this following confusion.
I want to download 3 hourly TRMM data from NASA website by using R, from the following website


##main Link
http://giovanni.gsfc.nasa.gov/giovanni/#service=ArAvTs&starttime=2008-12-31T00:00:00Z&endtime=2009-12-31T23:59:59Z&bbox=67,-50,67,-50&data=TRMM_3B42_007_precipitation
##the link allows to download data either in CSV format or png format. I prefer CSV format. The exact link to CSV file is
#Download link
http://giovanni.gsfc.nasa.gov/giovanni/daac-bin/serializer.pl?SESSION=BBF227CA-88F9-11E5-9F55-BE455C2ADB03:BBC3D554-88FA-11E5-BA70-60705B2ADB03:BBC8D64E-88FA-11E5-BA70-60705B2ADB03&FILE=g4.areaAvgTimeSeries.TRMM_3B42_007_precipitation.20081231-20091231.67E_50S_67E_50S.nc

In main link "bbox=67,-50,67,-50" shows the point where I want to download the data in the form of CSV file. The problem is that I have a vector of such points, a small part of which is below
structure(c(72, 71, 54, 67, 50, 53, 30, -50), .Dim = c(4L, 2L), .Dimnames = list(c("d", "e", "f", "g"), NULL))
How can I make a loop to download the data on given points automatically?

N.B.
It was fairly easy to download it, a few months ago. But ever since the outlook of website is changed. I cant use the previous codes that I use to use to download data.
The previous codes are
##############################################################################

setwd("C:\\Users\\Eliza\\Desktop\\hrly")

A few coordinates from the sample where I want to download data.

df2 <- data.frame(Longitude = c(45.75,46.25,46.75,), Latitude = c(34.75,34.25,33.75)) 

urlPattern1<-("http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=%s&north=%s&east=%s&south=%s&params=1%%7C3B42_V7&plot_type=Time+Plot&byr=1998&bmo=01&bdy=1&bhr=00&eyr=1998&emo=12&edy=31&ehr=21&begin_date=1998%%2F01%%2F01%%2F00&end_date=2014%%2F02%%2F28%%2F21&cbar=cdyn&cmin=&cmax=&yaxis=ydyn&ymin=&ymax=&yint=&ascres=0.25x0.25&global_cfg=tovas.global.cfg.pl&instance_id=TRMM_V7&prod_id=3B42&action=ASCII+Output")


fileDestination <- c("C:\\Users\\Eliza\\Desktop\\hrly") 
fileNames <- paste("precip", df2[,1], df2[,2], sep = "_")
 fileNames <- paste(fileNames, "txt", sep = ".")
 files <- file.path(fileDestination, fileNames) for (i in 1:nrow(df2)){    queryUrl <- sprintf(urlPattern1, df2[i, 1], df2[i, 2], df2[i, 1], df2[i, 2])    download.file(queryUrl, files[i])}
 ## import data in first file 
precip <- read.table(files[1], skip = 4, header = TRUE, na.strings = "-9990000000000000649570314828644352.0000",                    sep = "", check.names = FALSE, stringsAsFactors = FALSE) 
head(precip,2) 
Kindly help me out on it.
Thankyou very much in advance.
 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list