<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Muito obrigado Jônatan, ajudou muito!!!<br>
    </p>
    <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 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)
<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   -   ResearcherID: A-5790-2016
Researchgate: <a class="moz-txt-link-abbreviated" href="http://www.researchgate.net/profile/Alexandre_Santos10">www.researchgate.net/profile/Alexandre_Santos10</a>                       
LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
======================================================================</pre>
    <div class="moz-cite-prefix">Em 03/02/2017 16:59, Jônatan escreveu:<br>
    </div>
    <blockquote
cite="mid:CAEiHnvNi4mHfPyUu8AKShe2+Yv3j43DHjeQXkm=KhHPr2UG-QQ@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      <div>
        <div>require(raster); require(sp)</div>
        <div>set.seed(1)</div>
        <div>## Criando um raster</div>
        <div>r <- raster(nc=10, nr=10)</div>
        <div>r <- setValues(r, round(runif(ncell(r))* 255))</div>
        <div>#Consigo extrair os valores dos pixels de interesse dadas
          as coordenadas centrais dos mesmos</div>
        <div># x     <- c(54,18,54,54)</div>
        <div># y     <- c(27,81,9,63)</div>
        <div><br>
        </div>
        <div># inventando ptos que não coincidam com os centros das
          células</div>
        <div>x     <- c(54,18,54,54) </div>
        <div>x <- x + runif(length(x), 0, 35)</div>
        <div>y  <- c(27,81,9,63)</div>
        <div>y <- y - runif(length(y), 0, 17)</div>
        <div><br>
        </div>
        <div># data frame com pontos de interesse</div>
        <div>p <- data.frame(x,y)</div>
        <div># celulas do raster interceptadas pelos pontos</div>
        <div>p$cel <- cellFromXY(r, pontos)</div>
        <div>p$col <- colFromCell(r, p$cel)</div>
        <div>p$row <- rowFromCell(r, p$cel)</div>
        <div># adicionando as coordenadas centrais das células</div>
        <div>p.cen <- as.data.frame(xyFromCell(r, p$cel))</div>
        <div>names(p.cen) <- c("xc", "yc")</div>
        <div>p <- data.frame(p, p.cen)</div>
        <div># coordenadas das células à direita</div>
        <div><b>p.rigth <- as.data.frame(xyFromCell(r,
            cellFromRowCol(r, rownr = df$row, df$col + 1)))</b></div>
        <div><b>names(p.rigth) <- c("xr", "yr")</b></div>
        <div><b>p <- data.frame(p, p.rigth)</b></div>
        <div><br>
        </div>
        <div>p</div>
        <div>plot(r)</div>
        <div>text(r)</div>
        <div>points(p[, c("x", "y")], pch = 4, col = 2)</div>
        <div>points(p[, c("xc", "yc")], pch = 3, col = "gray", cex = 2)</div>
        <div>points(p[, c("xr", "yr")], pch = "_", col = "gray30", cex =
          2)</div>
        <div><br>
        </div>
        <div>library(plyr)</div>
        <div>vals2cols <- ldply(1:nrow(p),</div>
        <div>                   function(ir){</div>
        <div>                     getValuesBlock(r, </div>
        <div>                                    col = p$col[ir], </div>
        <div>                                    ncols = 2, </div>
        <div>                                    row = p$row[ir],</div>
        <div>                                    nrows = 1)</div>
        <div>                     </div>
        <div>                   }# end fun</div>
        <div>)</div>
        <div><br>
        </div>
        <div>df <- data.frame(p, vals2cols)</div>
        <div>df</div>
      </div>
      #dput(df) 
      <div>structure(list(x = c(76.9153374827001, 30.3619045177475,
        63.4591051060706, 88.7439421410672), y = c(16.2306145045441,
        77.3754617013037, 6.80067008268088, 54.8719934166875), cel =
        c(48, 6, 47, 18), col = c(8L, 6L, 7L, 8L), row = c(5, 1, 5, 2),
        xc = c(90, 18, 54, 90), yc = c(9, 81, 9, 63), xr = c(126, 54,
        90, 126 ), yr = c(9, 81, 9, 63), V1 = c(122, 229, 6, 253), V2 =
        c(187, 241, 122, 97)), .Names = c("x", "y", "cel", "col", "row",
        "xc", "yc", "xr", "yr", "V1", "V2"), row.names = c(NA, -4L),
        class = "data.frame")</div>
    </blockquote>
    <br>
  </body>
</html>