<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Muito obrigado Éder, funcionou perfeitamente!!!!!!<br>
<br>
Também tem outra alteração que resolve o meu problema e
aumenta a velocidade de processamento, uma vez que tenho rasters
muito grandes, sendo:<br>
<br>
radconvL <- function(x, band = 2) {<br>
Lmax <- switch(band, <br>
"2" = 120.64,<br>
"3" = 151.31,<br>
"4" = 157.57,<br>
"5" = 69.03,<br>
NA)<br>
<br>
if (is.na(Lmax)) stop("invalid band")<br>
Lmin = 0<br>
Qmax = 127<br>
setValues(x, Lmin + ((Lmax-Lmin)*values(x))/Qmax)<br>
}<br>
<br>
library(raster)<br>
b <- brick(system.file("external/rlogo.grd", package="raster"))<br>
test <- radconvL(b[[2]], band = 2)<br>
<br>
Abraços,<br>
<pre class="moz-signature" cols="72">--
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM) (+55) 65 9686-6970 (VIVO)
<a class="moz-txt-link-abbreviated" href="mailto:e-mails:alexandresantosbr@yahoo.com.br">e-mails:alexandresantosbr@yahoo.com.br</a>
<a class="moz-txt-link-abbreviated" href="mailto:alexandre.santos@cas.ifmt.edu.br">alexandre.santos@cas.ifmt.edu.br</a>
Lattes: <a class="moz-txt-link-freetext" href="http://lattes.cnpq.br/1360403201088680">http://lattes.cnpq.br/1360403201088680</a>
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: <a class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Alexandre_Santos10">https://www.researchgate.net/profile/Alexandre_Santos10</a>
LinkedIn: <a class="moz-txt-link-freetext" href="https://br.linkedin.com/in/alexandre-dos-santos-87961635">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a>
======================================================================
</pre>
<div class="moz-cite-prefix">Em 08/02/2016 12:14, Éder Comunello
escreveu:<br>
</div>
<blockquote
cite="mid:CABmC8gnHfswFsZPumokW-e563HRQY1mqGpzmNyCz52-NoJbDpQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif">Alexandre, bom dia!</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif">Fiz apenas uma pequena
alteração indicada no código.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default" style="">
<div class="gmail_default"><font face="monospace, monospace">###
<code r></font></div>
<div class="gmail_default"><font face="monospace, monospace">require(raster)</font></div>
<div class="gmail_default"><font face="monospace, monospace">require(sp)</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">#
RasterLayer inventado</font></div>
<div class="gmail_default"><font face="monospace, monospace">r
<- raster(nrows=10, ncols=10)</font></div>
<div class="gmail_default"><font face="monospace, monospace">r
<- setValues(r, 1:ncell(r))</font></div>
<div class="gmail_default"><font face="monospace, monospace">plot(r)</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">band2<-
as(r, 'SpatialGridDataFrame') ### transforma em
SpatialGridDataFrame</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">##Função
para conversão DN para radiância - LISS III
---------------------------</font></div>
<div class="gmail_default"><font face="monospace, monospace">radconvL<-function(x,
band = 2)</font></div>
<div class="gmail_default"><font face="monospace, monospace">{</font></div>
<div class="gmail_default"><font face="monospace, monospace">
Lmax <- switch(as.character(band), </font></div>
<div class="gmail_default"><font face="monospace, monospace">
"2" = 120.64,</font></div>
<div class="gmail_default"><font face="monospace, monospace">
"3" = 151.31,</font></div>
<div class="gmail_default"><font face="monospace, monospace">
"4" = 157.57,</font></div>
<div class="gmail_default"><font face="monospace, monospace">
"5" = 69.03,</font></div>
<div class="gmail_default"><font face="monospace, monospace">
NA)</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">
if (<a moz-do-not-send="true" href="http://is.na">is.na</a>(Lmax))
stop("invalid band")</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">
Lmin = 0</font></div>
<div class="gmail_default"><font face="monospace, monospace">
Qmax = 127</font></div>
<div class="gmail_default"><font face="monospace, monospace">
x <- as.vector(as.matrix(x))</font></div>
<div class="gmail_default"><font face="monospace, monospace">
results <- band2 ### <==== alterado aqui!!!</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">
x <- Lmin + ((Lmax-Lmin)*x)/Qmax</font></div>
<div class="gmail_default"><font face="monospace, monospace">
if (class(results) == "SpatialGridDataFrame")</font></div>
<div class="gmail_default"><font face="monospace, monospace">
results@data[, 1] <- x</font></div>
<div class="gmail_default"><font face="monospace, monospace">
else if (is.data.frame(x))</font></div>
<div class="gmail_default"><font face="monospace, monospace">
results <- data.frame(matrix(x, nrow =
nrow(results),</font></div>
<div class="gmail_default"><font face="monospace, monospace">
ncol = ncol(results)))</font></div>
<div class="gmail_default"><font face="monospace, monospace">
else results <- x</font></div>
<div class="gmail_default"><font face="monospace, monospace">
print(paste(band, Lmax))</font></div>
<div class="gmail_default"><font face="monospace, monospace">
print(results)</font></div>
<div class="gmail_default"><font face="monospace, monospace">
results</font></div>
<div class="gmail_default"><font face="monospace, monospace">}</font></div>
<div class="gmail_default"><font face="monospace, monospace">######--</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">teste2<-radconvL(band2,
band = 2)</font></div>
<div class="gmail_default"><span
style="font-family:monospace,monospace">spplot(teste2)</span><font
face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><span
style="font-family:monospace,monospace"><br>
</span></div>
<div class="gmail_default"><font face="monospace, monospace">teste3<-radconvL(band2,
band = 3)</font></div>
<div class="gmail_default"><font face="monospace, monospace">teste1<-radconvL(band2,
band = 1)</font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">###
</code></font></div>
<div class="gmail_default"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default"><br>
</div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr"><font style="font-size:small"
face="arial, helvetica, sans-serif">
<div style="font-family:'trebuchet
ms',sans-serif;display:inline"></div>
================================================<br>
Éder Comunello</font>
<div style="font-size:small"><span
style="font-family:arial,helvetica,sans-serif">PhD
Student in Agricultural Systems
Engineering (USP/Esalq)</span><br>
</div>
<div><span style="font-size:small">Brazilian
Agricultural Research Corporation (</span><font
style="font-size:small" face="arial,
helvetica, sans-serif">Embrapa)</font>
<div style="font-size:small"><font
face="arial, helvetica, sans-serif">Dourados,
MS, Brazil [</font>22 16.5'S, 54 49.0'W<span
style="font-family:arial,helvetica,sans-serif">]</span></div>
<div>
<div><br>
</div>
<div><br>
</div>
</div>
<div style="font-size:small"><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>