Erro em download de dados da internet

Bom dia, pessoal Estou tentando rodar o seguinte codigo: ### year.ini<- 2010 #ano inicial year.end<- 2013 # ano final url<- paste0(' http://power.larc.nasa.gov/cgi-bin/cgiwrap/solar/agro.cgi?email=agroclim%40larc.nasa.gov&step=1&lat=',sep=lat, '&lon=', sep = long, '&ms=1&ds=1&ys=', sep = year.ini, '&me=12&de=31&ye=', sep = year.end, '&p=toa_dwn&p=swv_dwn&p=lwv_dwn&p=T2M&p=T2MN&p=T2MX&p=RH2M&p=DFP2M&p=RAIN&p=WS10M&submit=Submit') download.file(url, "data.txt", method = "auto", quiet = FALSE, mode = "w", cacheOK = TRUE) ### entretanto, se a diferenca entre os anos (inicial e final) for >8, aparece a seguinte msg: "Error in download.file(url.a, "data.txt", method = "auto", quiet = FALSE, : cannot open URL ' http://power.larc.nasa.gov/cgi-bin/cgiwrap/solar/agro.cgi?email=agroclim%40l... ' In addition: Warning message: In download.file(url.a, "data.txt", method = "auto", quiet = FALSE, : InternetOpenUrl failed: 'O tempo limite da operação foi atingido' " Por outro lado, se forem poucos anos, esta rodando normalmente. Alguem saberia como resolver esse problema? Obrigado, -- Leonardo Amaral Monteiro - Agronomist MSc in Agrometeorology PhD Student in Engineering Agricultural Systems Sao Paulo University - College of Agriculture "Luiz de Queiroz" - Brazil Landscape System Analysis - ZALF Institute, Müncheberg - Germany ====================================================== Mestre em Agrometeorologia Doutorando em Engenharia de Sistemas Agrícolas Universidade de Sao Paulo - Escola Superior de Agricultura "Luiz de Queiroz" Landscape System Analysis - Instituto ZALF - Müncheberg - Alemanha ====================================================== Phone: +55 19 34294123 - R. 236

Leonardo, bom dia! Não tive problemas aqui, embora tenho feito uns ajustes no código. Depois de gerar a URL, experimente utilizar browseURL(url). Se abrir no seu navegador deve funcionar com download.file() também. Também seria possível usar read.table() direto, mas para volumes maiores, sugiro fazer o download primeiro. ### <code r> urlBase = 'http://power.larc.nasa.gov/cgi-bin/cgiwrap/solar/agro.cgi' lat = -22 lon = -54 ys = 2000 # ano inicial ye = 2013 # ano final email = "agroclim@larc.nasa.gov" url <- paste0(urlBase, '?email=', email, '&step=1&lat=', lat, '&lon=', lon, '&ms=1&ds=1&ys=', ys, '&me=12&de=31&ye=', ye, '&p=toa_dwn&p=swv_dwn&p=lwv_dwn&p=T2M&p=T2MN&p=T2MX&p=RH2M&p=DFP2M&p=RAIN&p=WS10M&submit=Submit') #browseURL(url) download.file(url, "data.txt", mode = "wb") # trying URL ' http://power.larc.nasa.gov/cgi-bin/cgiwrap/solar/agro.cgi?email=agroclim@lar... ' # Content type 'text/plain' length unknown # opened URL # downloaded 445 Kb ### </code> Éder Comunello <c <comunello.eder@gmail.com>omunello.eder@gmail.com> Dourados, MS - [22 16.5'S, 54 49'W]
participantes (2)
-
Leonardo Monteiro
-
Éder Comunello