<div dir="ltr">Alexandre, boa tarde!<div><br></div><div>Fiz algumas alterações em cima do seu CMR. Veja se há algo que possa lhe servir.<br><div><br></div><div><div><font face="courier new, monospace">#<code r></font></div>
<div><font face="courier new, monospace">setwd('C:/LAB/RBASICS/tmp'); getwd()</font></div><div><font face="courier new, monospace">require(raster); require(rgdal)</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">### Download a partir de uma lista de links</font></div><div><font face="courier new, monospace">##############################################################################</font></div>
<div><font face="courier new, monospace">### A opção "get link" gera algo como "<a href="https://www.dropbox.com/s/XXXXXX/file.png">https://www.dropbox.com/s/XXXXXX/file.png</a>"</font></div><div><font face="courier new, monospace">### para download.file() Use "XXXXXX/file.png" após "<a href="http://dl.dropbox.com/s/">http://dl.dropbox.com/s/</a>"</font></div>
<div><font face="courier new, monospace">### XXXXXX = token</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### links obtidos no seu script</font></div><div><font face="courier new, monospace">links <- c(</font></div>
<div><font face="courier new, monospace">"<a href="https://www.dropbox.com/s/8b99gn9ve1yo7is/Fig1-0_00_00.png">https://www.dropbox.com/s/8b99gn9ve1yo7is/Fig1-0_00_00.png</a>", </font></div><div><font face="courier new, monospace">"<a href="https://www.dropbox.com/s/8b99gn9ve1yo7is/Fig2-0_20_00.png">https://www.dropbox.com/s/8b99gn9ve1yo7is/Fig2-0_20_00.png</a>", ### erro! mesmo token do anterior!</font></div>
<div><font face="courier new, monospace">"<a href="https://www.dropbox.com/s/bo6gbt3ca6xwxm0/Fig3-0_40_00.png">https://www.dropbox.com/s/bo6gbt3ca6xwxm0/Fig3-0_40_00.png</a>")</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">tokens <- gsub("^.*/s/","",dirname(links))</font></div><div><font face="courier new, monospace">fileNames <- basename(links)</font></div><div>
<font face="courier new, monospace">newLinks <- file.path("<a href="http://dl.dropbox.com/s">http://dl.dropbox.com/s</a>", tokens, fileNames); newLinks</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">for (a in newLinks) {</font></div><div><font face="courier new, monospace"> tryCatch(download.file(a, dest=basename(a), mode='wb'),</font></div><div><font face="courier new, monospace"> error=function(...) print("Falha no download!"))} </font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### Verificando arquivos baixados corretamente</font></div><div><font face="courier new, monospace">##############################################################################</font></div>
<div><font face="courier new, monospace">fileInfo <- <a href="http://file.info">file.info</a>(fileNames); fileInfo ### observe o segundo arquivo</font></div><div><font face="courier new, monospace">files.OK <- fileNames[fileInfo$size>0 & !<a href="http://is.na">is.na</a>(fileInfo$size)]; files.OK</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### Operando arquivos baixados corretamente</font></div><div><font face="courier new, monospace">##############################################################################</font></div>
<div><font face="courier new, monospace">for (b in files.OK) {</font></div><div><font face="courier new, monospace"> t <- strsplit(b,"-|\\.")[[1]][2]</font></div><div><font face="courier new, monospace"> tempo <- gsub("_", ":", t)</font></div>
<div><font face="courier new, monospace"> r <- raster(b); #image(r) ### comentado para otimizar</font></div><div><font face="courier new, monospace"> XYZ <- data.frame(coordinates(r), values(r), rep(tempo))</font></div>
<div><font face="courier new, monospace"> XYZ.0 <- XYZ[XYZ[,3]==0,]</font></div><div><font face="courier new, monospace"> outName <- paste0('XYZ.0-', t, '.txt')</font></div><div><font face="courier new, monospace"> write.table(XYZ, outName, row.names=F)</font></div>
<div><font face="courier new, monospace"> message(noquote(paste(outName, "salvo em", getwd()))) </font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace">#</code></font></div>
</div><div><br></div><div><br></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>
Dourados, MS - [22 16.5'S, 54 49'W]</div></div></div></div></div>