<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Muito bem pesado Thiago, vou atentar a isso.<br>
    <br>
            E agradeço também ao Cesar, nunca havia usado a ferramenta
    de depuração e resolveu o meu problema.<br>
    <br>
    Segue minha função final, se alguém for trabalhar com imagens do
    Resourcesat e sensor LISS IIII:<br>
    <br>
    ##Função para conversão DN para radiância - LISS III
    ---------------------------<br>
    radconvL<-function(x, band = 2)<br>
    {<br>
        BAND <- c("2", "3", "4", "5")<br>
        band <- pmatch(band, BAND)<br>
        if (is.na(band))<br>
            stop("invalid band")<br>
                <br>
        Lmin = 0<br>
        Qmax = 127<br>
        x <- as.vector(as.matrix(x))<br>
        results <- x<br>
                <br>
        if (band == 2) {<br>
        Lmax = 120.64<br>
        }<br>
        else if (band == 3) {<br>
        Lmax = 151.31<br>
        }<br>
        else if (band == 4) {<br>
        Lmax = 157.57<br>
        }<br>
        else if(band == 5) {<br>
        Lmax = 69.03<br>
        }<br>
    <br>
        x <- Lmin + ((Lmax-Lmin)*x)/Qmax<br>
        if (class(results) == "SpatialGridDataFrame")<br>
            results@data[, 1] <- x<br>
        else if (is.data.frame(x))<br>
            results <- data.frame(matrix(x, nrow = nrow(results),<br>
                ncol = ncol(results)))<br>
        else results <- x<br>
        results    <br>
    }<br>
######--------------------------------------------------------------------------<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>                   
======================================================================
</pre>
    <div class="moz-cite-prefix">Em 16/12/2015 21:11, Thiago V. dos
      Santos escreveu:<br>
    </div>
    <blockquote
      cite="mid:1851087109.3696.1450311113347.JavaMail.yahoo@mail.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff;
        font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica
        Neue, Helvetica, Arial, Lucida Grande,
        sans-serif;font-size:13px">
        <div id="yui_3_16_0_1_1450310535638_3596"><span
            id="yui_3_16_0_1_1450310535638_3595">Uma opção mais
            eficiente (e provavelmente mais legível) é aproveitar os
            recursos de vetorização do R.</span></div>
        <div id="yui_3_16_0_1_1450310535638_3702"><span><br>
          </span></div>
        <div id="yui_3_16_0_1_1450310535638_3597">O que eu tenho feito é
          criar um raster stack com todas as bandas do landsat. Depois,
          eu crio uma lista com os parametros de calibração de cada
          banda (que você vai ler nos arquivos de calibração). Funciona
          melhor se você deixar todos os arquivos - imagens e arquivos
          de calibração - em uma pasta só.</div>
        <div id="yui_3_16_0_1_1450310535638_3598"><br>
        </div>
        <div id="yui_3_16_0_1_1450310535638_3662">Assumindo que o raster
          stack tem o mesmo tamanho da lista, você pode aplicar uma
          multiplicação direta para fazer a calibração.</div>
        <div id="yui_3_16_0_1_1450310535638_3660"> </div>
        <div class="signature" id="yui_3_16_0_1_1450310535638_3601">Greetings,
          <div id="yui_3_16_0_1_1450310535638_3600"> -- Thiago V. dos
            Santos</div>
          <div id="yui_3_16_0_1_1450310535638_3659"><br>
          </div>
          <div id="yui_3_16_0_1_1450310535638_3658">PhD student</div>
          <div id="yui_3_16_0_1_1450310535638_3663">Land and Atmospheric
            Science</div>
          <div id="yui_3_16_0_1_1450310535638_3664">University of
            Minnesota</div>
        </div>
        <br>
        <div class="qtdSeparateBR"><br>
          <br>
        </div>
        <div class="yahoo_quoted" style="display: block;">
          <div style="font-family: HelveticaNeue-Light, Helvetica Neue
            Light, Helvetica Neue, Helvetica, Arial, Lucida Grande,
            sans-serif; font-size: 13px;">
            <div style="font-family: HelveticaNeue, Helvetica Neue,
              Helvetica, Arial, Lucida Grande, sans-serif; font-size:
              16px;">
              <div dir="ltr"><font size="2" face="Arial"> On Tuesday,
                  December 15, 2015 1:46 PM, Cesar Rabak
                  <a class="moz-txt-link-rfc2396E" href="mailto:cesar.rabak@gmail.com"><cesar.rabak@gmail.com></a> wrote:<br>
                </font></div>
              <br>
              <br>
              <div class="y_msg_container">
                <div id="yiv0559910571">
                  <div>
                    <div dir="ltr">Alexandre,
                      <div><br clear="none">
                      </div>
                      <div>A melhor forma de você atacar esse problema é
                        usar as facilidades de depuração do R:</div>
                      <div><br clear="none">
                      </div>
                      <div>> ?debug</div>
                      <div><br clear="none">
                      </div>
                      <div>para ver a documentação do depurador padrão.</div>
                      <div><br clear="none">
                      </div>
                      <div>Um tutorialzinho sobre seu uso pode ser
                        encontrado aqui: <a moz-do-not-send="true"
                          rel="nofollow" shape="rect" target="_blank"
                          href="http://www.biostat.jhsph.edu/%7Erpeng/docs/R-debug-tools.pdf">http://www.biostat.jhsph.edu/~rpeng/docs/R-debug-tools.pdf</a><br
                          clear="none">
                        <br clear="none">
                        HTH</div>
                      <div>--</div>
                      <div>Cesar Rabak</div>
                      <div><br clear="none">
                      </div>
                      <div><br clear="none">
                      </div>
                    </div>
                    <div class="yiv0559910571gmail_extra"><br
                        clear="none">
                      <div class="yiv0559910571gmail_quote">2015-12-15
                        18:47 GMT-02:00 ASANTOS <span dir="ltr"><<a
                            moz-do-not-send="true" rel="nofollow"
                            shape="rect"
                            ymailto="mailto:alexandresantosbr@yahoo.com.br"
                            target="_blank"
                            href="mailto:alexandresantosbr@yahoo.com.br"><a class="moz-txt-link-abbreviated" href="mailto:alexandresantosbr@yahoo.com.br">alexandresantosbr@yahoo.com.br</a></a>></span>:<br
                          clear="none">
                        <div class="yiv0559910571yqt2879652483"
                          id="yiv0559910571yqt42991">
                          <blockquote class="yiv0559910571gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex;">Caros
                            Listeiros,<br clear="none">
                            <br clear="none">
                            <br clear="none">
                                     Estou tentando criar uma função
                            abaixo para converter um
                            SpatialGridDataFrame originado de uma imagem
                            de satélite para reflectância, mas a função
                            que eu criei (radconvL()) pelo excesso de
                            else if não esta funcionando. Meu problema é
                            que não dá erro, o que normalmente ajuda a
                            detectar o problema, mas no meu caso a
                            função nem funciona, segue meu CRM abaixo,
                            alguém poderia me ajudar?<br clear="none">
                            <br clear="none">
                            require(raster)<br clear="none">
                            require(sp)<br clear="none">
                            <br clear="none">
                            # RasterLayer inventado<br clear="none">
                            r <- raster(nrows=10, ncols=10)<br
                              clear="none">
                            r <- setValues(r, 1:ncell(r))<br
                              clear="none">
                            plot(r)<br clear="none">
                            <br clear="none">
                            band2<- as(r, 'SpatialGridDataFrame') 
                            ### transforma em SpatialGridDataFrame<br
                              clear="none">
                            <br clear="none">
                            <br clear="none">
                            <br clear="none">
                            ##Função para conversão DN para reflectância<br
                              clear="none">
                            radconvL<-function(x, band = 2)<br
                              clear="none">
                            {<br clear="none">
                                BAND <- c("2", "3", "4", "5")<br
                              clear="none">
                                band <- pmatch(band, BAND)<br
                              clear="none">
                                Lmin = 0<br clear="none">
                                Qmax = 127<br clear="none">
                            <br clear="none">
                                if (<a moz-do-not-send="true"
                              rel="nofollow" shape="rect"
                              target="_blank" href="http://is.na/">is.na</a>(band))<br
                              clear="none">
                                    stop("invalid band")<br clear="none">
                            <br clear="none">
                                if (band == 2) {<br clear="none">
                                Lmax = 120.64<br clear="none">
                                results <- x<br clear="none">
                                x <- as.vector(as.matrix(x))<br
                              clear="none">
                                x <- Lmin + ((Lmax-Lmin)*x)/Qmax<br
                              clear="none">
                                if (class(results) ==
                            "SpatialGridDataFrame")<br clear="none">
                                    results@data[, 1] <- x<br
                              clear="none">
                                else if (is.data.frame(x))<br
                              clear="none">
                                    results <- data.frame(matrix(x,
                            nrow = nrow(results),<br clear="none">
                                        ncol = ncol(results)))<br
                              clear="none">
                                else results <- x<br clear="none">
                                results<br clear="none">
                                }<br clear="none">
                                else if (band == 3) {<br clear="none">
                                Lmax = 151.31<br clear="none">
                                results <- x<br clear="none">
                                x <- as.vector(as.matrix(x))<br
                              clear="none">
                                x <- Lmin + ((Lmax-Lmin)*x)/Qmax<br
                              clear="none">
                                if (class(results) ==
                            "SpatialGridDataFrame")<br clear="none">
                                    results@data[, 1] <- x<br
                              clear="none">
                                else if (is.data.frame(x))<br
                              clear="none">
                                    results <- data.frame(matrix(x,
                            nrow = nrow(results),<br clear="none">
                                        ncol = ncol(results)))<br
                              clear="none">
                                else results <- x<br clear="none">
                                results<br clear="none">
                                }<br clear="none">
                                else if (band == 4) {<br clear="none">
                                Lmax = 157.57<br clear="none">
                                results <- x<br clear="none">
                                x <- as.vector(as.matrix(x))<br
                              clear="none">
                                x <- Lmin + ((Lmax-Lmin)*x)/Qmax<br
                              clear="none">
                                if (class(results) ==
                            "SpatialGridDataFrame")<br clear="none">
                                    results@data[, 1] <- x<br
                              clear="none">
                                else if (is.data.frame(x))<br
                              clear="none">
                                    results <- data.frame(matrix(x,
                            nrow = nrow(results),<br clear="none">
                                        ncol = ncol(results)))<br
                              clear="none">
                                else results <- x<br clear="none">
                                results<br clear="none">
                                }<br clear="none">
                                else if(band == 5) {<br clear="none">
                                Lmax = 69.03<br clear="none">
                                results <- x<br clear="none">
                                x <- as.vector(as.matrix(x))<br
                              clear="none">
                                x <- Lmin + ((Lmax-Lmin)*x)/Qmax<br
                              clear="none">
                                if (class(results) ==
                            "SpatialGridDataFrame")<br clear="none">
                                    results@data[, 1] <- x<br
                              clear="none">
                                else if (is.data.frame(x))<br
                              clear="none">
                                    results <- data.frame(matrix(x,
                            nrow = nrow(results),<br clear="none">
                                        ncol = ncol(results)))<br
                              clear="none">
                                else results <- x<br clear="none">
                                results<br clear="none">
                                }<br clear="none">
                            }<br clear="none">
                            ######<br clear="none">
                            teste<-radconvL(band2, band=2) ## Aqui
                            não funciona e não sei porque<br
                              clear="none">
                            teste<br clear="none">
                            <br clear="none">
                            <br clear="none">
                            Muito obrigado,<br clear="none">
                            <br clear="none">
                            -- <br clear="none">
======================================================================<br
                              clear="none">
                            Alexandre dos Santos<br clear="none">
                            Proteção Florestal<br clear="none">
                            IFMT - Instituto Federal de Educação,
                            Ciência e Tecnologia de Mato Grosso<br
                              clear="none">
                            Campus Cáceres<br clear="none">
                            Caixa Postal 244<br clear="none">
                            Avenida dos Ramires, s/n<br clear="none">
                            Bairro: Distrito Industrial<br clear="none">
                            Cáceres - MT                      CEP:
                            78.200-000<br clear="none">
                            Fone: (+55) 65 8132-8112 (TIM)   (+55) 65
                            9686-6970 (VIVO)<br clear="none">
                            <a moz-do-not-send="true" rel="nofollow"
                              shape="rect"
                              ymailto="mailto:e-mails%3Aalexandresantosbr@yahoo.com.br"
                              target="_blank"
                              href="mailto:e-mails%3Aalexandresantosbr@yahoo.com.br">e-mails:alexandresantosbr@yahoo.com.br</a><br
                              clear="none">
                                    <a moz-do-not-send="true"
                              rel="nofollow" shape="rect"
                              ymailto="mailto:alexandre.santos@cas.ifmt.edu.br"
                              target="_blank"
                              href="mailto:alexandre.santos@cas.ifmt.edu.br">alexandre.santos@cas.ifmt.edu.br</a><br
                              clear="none">
                            Lattes: <a moz-do-not-send="true"
                              rel="nofollow" shape="rect"
                              target="_blank"
                              href="http://lattes.cnpq.br/1360403201088680">http://lattes.cnpq.br/1360403201088680</a><br
                              clear="none">
======================================================================<br
                              clear="none">
                            <br clear="none">
_______________________________________________<br clear="none">
                            R-br mailing list<br clear="none">
                            <a moz-do-not-send="true" rel="nofollow"
                              shape="rect"
                              ymailto="mailto:R-br@listas.c3sl.ufpr.br"
                              target="_blank"
                              href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br
                              clear="none">
                            <a moz-do-not-send="true" rel="nofollow"
                              shape="rect" target="_blank"
                              href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br
                              clear="none">
                            Leia o guia de postagem (<a
                              moz-do-not-send="true" rel="nofollow"
                              shape="rect" target="_blank"
                              href="http://www.leg.ufpr.br/r-br-guia"><a class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a></a>)
                            e fornea cdigo mnimo reproduzvel.</blockquote>
                        </div>
                      </div>
                      <br clear="none">
                    </div>
                  </div>
                </div>
                <br>
                <div class="yqt2879652483" id="yqt12144">_______________________________________________<br
                    clear="none">
                  R-br mailing list<br clear="none">
                  <a moz-do-not-send="true" shape="rect"
                    ymailto="mailto:R-br@listas.c3sl.ufpr.br"
                    href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br
                    clear="none">
                  <a moz-do-not-send="true" shape="rect"
                    href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                    target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br
                    clear="none">
                  Leia o guia de postagem (<a moz-do-not-send="true"
                    shape="rect" href="http://www.leg.ufpr.br/r-br-guia"
                    target="_blank">http://www.leg.ufpr.br/r-br-guia</a>)
                  e forne� c�igo m�imo reproduz�el.</div>
                <br>
                <br>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
R-br mailing list
<a class="moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a>
<a class="moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
    </blockquote>
    <br>
  </body>
</html>