<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Muito obrigado Éder e Thiago,<br>
    <br>
           Acredito que colocamos uma pedra sobre a questão!!! Priorizar
    raster() é = ganho de velocidade de processamentos e menor uso de
    memória.<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 18/02/2016 06:28, Éder Comunello
      escreveu:<br>
    </div>
    <blockquote
cite="mid:CABmC8gmJu_oxrL8smY2a=qw+2tYOodtbk=6UnoEs6fKEqaVNeQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:verdana,sans-serif">Senhores, 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 o exercício abaixo,
          me preocupando mais com uso de memória. Nesse quesito o pacote
          {raster} traz grandes vantagens. Além disso, formatos binários
          otimizam a leitura e ocupam menor espaço em disco.</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">setwd("D:/Temp")</font></div>
          <div class="gmail_default"><font face="monospace, monospace">sapply(c("raster",
              "sp", "rgdal"), require, char=T)</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">url0
              <- "<a moz-do-not-send="true"
href="http://download.osgeo.org/geotiff/samples/spot/chicago/UTM2GTIF.TIF">http://download.osgeo.org/geotiff/samples/spot/chicago/UTM2GTIF.TIF</a>"</font></div>
          <div class="gmail_default"><font face="monospace, monospace">fn
                <- basename(url0)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              download.file(url0, fn, mode="wb")</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Leitura com pacotes {raster} e {readGDAL}...</font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              O pacote {raster} acessa informações do arquivo em disco, </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              enquanto {readGDAL} carrega na memória.</font></div>
          <div class="gmail_default"><font face="monospace, monospace">img1
              <- raster(fn)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">img2
              <- readGDAL(fn)</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">par(mfrow=c(1,2))</font></div>
          <div class="gmail_default"><font face="monospace, monospace">image(img1,
              asp=T, axes=F, ann=F); image(img2, asp=T)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">par(mfrow=c(1,1))</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">print(object.size(img1),
              units="Kb") #   11.4 Kb</font></div>
          <div class="gmail_default"><font face="monospace, monospace">print(object.size(img2),
              units="Kb") # 2540.9 Kb</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Você pode converter seu objeto para {raster}...</font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Mas em princípio ele vai ficar residente na memória</font></div>
          <div class="gmail_default"><font face="monospace, monospace">img2a
              <- raster(img2)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">print(object.size(img2a),
              units="Kb") # 2548 Kb</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Para economizar memória, você pode salvar no disco e
              reabrir com {raster}</font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Pode usar qualquer formato aceito por raster, inclusive
              ascii</font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Mas formatos binários otimizam o acesso e leitura</font></div>
          <div class="gmail_default"><font face="monospace, monospace">writeFormats()</font></div>
          <div class="gmail_default"><font face="monospace, monospace">writeRaster(img2a,
              "novo.tif", "GTiff", overwrite=F)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">writeRaster(img2a,
              "novo.asc", "ascii", overwrite=F)</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">rm(img2,
              img2a) ### apagar intermediários pra liberar memória</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default">
            <div class="gmail_default"><font face="monospace, monospace">system.time(img3a
                <- raster("novo.tif")) # 0.03s</font></div>
            <div class="gmail_default"><font face="monospace, monospace">system.time(img3b
                <- raster("novo.asc")) # 0.06s</font></div>
            <div class="gmail_default"><br>
            </div>
          </div>
          <div class="gmail_default"><font face="monospace, monospace">print(object.size(img3a),
              units="Kb") # 11.4 Kb</font></div>
          <div class="gmail_default"><font face="monospace, monospace">print(object.size(img3b),
              units="Kb") # 11.3 Kb</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace"><a
                moz-do-not-send="true" href="http://file.info">file.info</a>(dir(patt="novo\\."))
              ### tamanho no disco</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
                          size isdir mode               mtime          
                  ctime               atime exe</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              novo.asc 2289309 FALSE  666 2016-02-18 05:50:06 2016-02-18
              05:50:02 2016-02-18 05:50:02  no</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              novo.tif 1249547 FALSE  666 2016-02-18 05:49:48 2016-02-18
              05:49:48 2016-02-18 05:49:48  no</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
               tamanho no disco em "Mb"</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><a
                moz-do-not-send="true" href="http://file.info">file.info</a>(dir(patt="novo\\."))$size/1024^2
              # [1] 2.183255 1.191661</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">par(mfrow=c(1,2))</font></div>
          <div class="gmail_default"><font face="monospace, monospace">image(img3a,
              asp=T); image(img3b, asp=T)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">par(mfrow=c(1,1))</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Geotiff preserva mais atributos...</font></div>
          <div class="gmail_default"><font face="monospace, monospace">img3a</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              class       : RasterLayer </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              dimensions  : 929, 699, 649371  (nrow, ncol, ncell)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              resolution  : 10, 10  (x, y)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              extent      : 444650, 451640, 4631220, 4640510  (xmin,
              xmax, ymin, ymax)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              coord. ref. : +proj=utm +zone=16 +datum=NAD27 +units=m
              +no_defs +ellps=clrk66
              +nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              data source : D:\Temp\novo.tif </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              names       : novo </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              values      : 6, 255  (min, max)</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">img3b</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              class       : RasterLayer </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              dimensions  : 929, 699, 649371  (nrow, ncol, ncell)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              resolution  : 10, 10  (x, y)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              extent      : 444650, 451640, 4631220, 4640510  (xmin,
              xmax, ymin, ymax)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              coord. ref. : NA </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              data source : D:\Temp\novo.asc </font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              names       : novo </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              </code></font></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">
                        <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>
                            </font><font style="font-size:12.8px"
                              face="arial, helvetica, sans-serif"><span
                                style="font-size:small">================================================</span><br>
                              Éder Comunello</font>
                            <div style="font-size:12.8px"><span
                                style="font-family:arial,helvetica,sans-serif">Agronomist
                                (UEM), MSc in Environ. Sciences (UEM)</span><font
                                face="arial, helvetica, sans-serif"><br>
                              </font></div>
                            <div style="font-size:12.8px">
                              <div style="font-size:small"><span
                                  style="font-family:arial,helvetica,sans-serif">DSc
                                  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>
                              <div>
                                <div><font style="font-size:small"
                                    face="arial, helvetica, sans-serif">Dourados,
                                    MS, Brazil </font><font size="2"
                                    face="arial, helvetica, sans-serif">|<O>|</font></div>
                                <div style="font-size:small"><span
                                    style="font-family:arial,helvetica,sans-serif">================================================</span><br>
                                </div>
                              </div>
                            </div>
                            <div style="font-size:small"><font
                                face="arial, helvetica, sans-serif">GEO, </font>-22.2752,
                              -54.8182, 408m<span
                                style="font-family:arial,helvetica,sans-serif"><br>
                              </span></div>
                            <div style="font-size:12.8px"><span
                                style="font-size:small;font-family:arial,helvetica,sans-serif">UTC-04:00
                                / DST: UTC-03:00</span></div>
                            <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>
          <br>
          <div class="gmail_quote"><br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>