<div dir="ltr"><div>p.cen <- as.data.frame(xyFromCell(r, df$cel))</div><div>names(p.cen) <- c("xc", "yc")</div><div>df <- data.frame(df, p.cen)<br></div><div>df</div>#dput(df)<div>#structure(list(x = -150, y = -80, cel = 91, col = 1L, row = 10, V1 = 61, V2 = 15, xc = -162, yc = -81), .Names = c("x", "y", "cel", "col", "row", "V1", "V2", "xc", "yc"), row.names = c(NA, -1L), class = "data.frame")<div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-03 14:00 GMT-02:00 ASANTOS <span dir="ltr"><<a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Obrigado Jônatan,</p>
<p> Perfeita essa função usando getValuesBlocke consegui fazer
a extração de 10 valores na horizontal à partir de uma coordenada
arbitrária como xy(-150,80), porém não consigo agora capturar além
dos valores dos pixel a coordenada central desses pixel pelo
output dado pela função, poderia me ajudar?</p>
<p>No meu caso tentei usar a função xyFromCell():</p>
<p><span class="">require(raster); require(sp)<br>
set.seed(1)<br>
## Criando um raster<br>
r <- raster(nc=10, nr=10)<br>
r <- setValues(r, round(runif(ncell(r))* 255))<br>
#Consigo extrair os valores dos pixels de interesse dadas as
coordenadas centrais dos mesmos<br></span>
x <- c(-150)<br>
y <- c(-80)<span class=""><br>
p <- data.frame(x,y)<br>
pontos <- SpatialPoints(p)<br>
<br>
p$cel <- cellFromXY(r, pontos)<br>
p$col <- colFromCell(r, p$cel)<br>
p$row <- rowFromCell(r, p$cel)<br>
p<br>
plot(r)<br>
text(r)<br>
points(pontos, pch = 4, col = 2)<br>
<br>
library(plyr)<br>
vals2cols <- ldply(1:nrow(p),<br>
function(ir){<br>
getValuesBlock(r, <br>
<wbr> col = p$col[ir], <br></span>
<wbr> ncols = 10, <br><span class="">
<wbr> row = p$row[ir],<br>
<wbr> nrows = 1)<br>
<br>
}# end fun<br>
)<br>
<br>
df <- data.frame(p, vals2cols)<br>
df<br>
<br></span>
p.cen <- xyFromCell(r, vals2cols); p.cen<br>
</p>
<p>#END--------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-----------------<br>
</p><span class="">
<pre class="m_8510547872449408250moz-signature" cols="72">--
==============================<wbr>==============================<wbr>==========
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: <a href="tel:+55%2065%2099686-6970" value="+5565996866970" target="_blank">(+55) 65 99686-6970</a> (VIVO) <a href="tel:+55%2065%203221-2674" value="+556532212674" target="_blank">(+55) 65 3221-2674</a> (FIXO)
<a class="m_8510547872449408250moz-txt-link-abbreviated" href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@<wbr>yahoo.com.br</a>
<a class="m_8510547872449408250moz-txt-link-abbreviated" href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.<wbr>br</a>
Lattes: <a class="m_8510547872449408250moz-txt-link-freetext" href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/<wbr>1360403201088680</a>
OrcID: <a href="http://orcid.org/0000-0001-8232-6722" target="_blank">orcid.org/0000-0001-8232-6722</a> - ResearcherID: A-5790-2016
Researchgate: <a class="m_8510547872449408250moz-txt-link-abbreviated" href="http://www.researchgate.net/profile/Alexandre_Santos10" target="_blank">www.researchgate.net/profile/<wbr>Alexandre_Santos10</a>
LinkedIn: <a href="http://br.linkedin.com/in/alexandre-dos-santos-87961635" target="_blank">br.linkedin.com/in/alexandre-<wbr>dos-santos-87961635</a>
Mendeley:<a href="http://www.mendeley.com/profiles/alexandre-dos-santos6/" target="_blank">www.mendeley.com/<wbr>profiles/alexandre-dos-<wbr>santos6/</a>
==============================<wbr>==============================<wbr>==========</pre>
</span><div><div class="h5"><div class="m_8510547872449408250moz-cite-prefix">Em 01/02/2017 22:01, Jônatan escreveu:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>use a função getValuesBlock do raster.</div>
<div><br>
</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>p <- data.frame(x,y)</div>
<div>pontos <- SpatialPoints(p)</div>
<div><br>
</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>p</div>
<div>plot(r)</div>
<div>text(r)</div>
<div>points(pontos, pch = 4, col = 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> </div>
<div>df <- data.frame(p, vals2cols)</div>
<div>df</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-01-26 17:43 GMT-02:00 ASANTOS via
R-br <span dir="ltr"><<a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Prezados
Membros,<br>
<br>
Tenho um raster hipotético r:<br>
<br>
require(raster); require(sp)<br>
<br>
## Criando um raster<br>
r <- raster(nc=10, nr=10)<br>
r <- setValues(r, round(runif(ncell(r))* 255))<br>
<br>
Consigo extrair os valores dos pixels de interesse
dadas as coordenadas centrais dos mesmos:<br>
<br>
x <- c(54,18,54,54)<br>
y <- c(27,81,9,63)<br>
<br>
pontos <- SpatialPoints(cbind(x,y))<br>
<br>
cells <- cellFromXY(r, pontos); cells<br>
p.cen <- xyFromCell(r, cells); p.cen<br>
<br>
values <- extract(r,p.cen)<br>
dados<-cbind(p.cen,cells,value<wbr>s)<br>
<br>
No entanto, eu gostaria de encontrar um modo para
extrair o valor dos pixels, no qual, eu selecionaria uma
coordenada e a função realizaria a extração dos pixels de
linhas verticais inteiras do raster a cada dois pixels à
partir da coordenada dada, por exemplo?<br>
<br>
Alguém poderia me dar uma ideia de como chegar a esse
resultado?<br>
<br>
Obrigado,<br>
<br>
-- <br>
==============================<wbr>==============================<wbr>==========<br>
Alexandre dos Santos<br>
Proteção Florestal<br>
IFMT - Instituto Federal de Educação, Ciência e Tecnologia
de Mato Grosso<br>
Campus Cáceres<br>
Caixa Postal 244<br>
Avenida dos Ramires, s/n<br>
Bairro: Distrito Industrial<br>
Cáceres - MT CEP: 78.200-000<br>
Fone: <a href="tel:%28%2B55%29%2065%2099686-6970" value="+5565996866970" target="_blank">(+55) 65 99686-6970</a>
(VIVO) <a href="tel:%28%2B55%29%2065%203221-2674" value="+556532212674" target="_blank">(+55) 65 3221-2674</a>
(FIXO)<br>
<a href="mailto:e-mails%3Aalexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yaho<wbr>o.com.br</a><br>
<a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.<wbr>br</a><br>
Lattes: <a href="http://lattes.cnpq.br/1360403201088680" rel="noreferrer" target="_blank">http://lattes.cnpq.br/13604032<wbr>01088680</a><br>
OrcID: <a href="http://orcid.org/0000-0001-8232-6722" rel="noreferrer" target="_blank">orcid.org/0000-0001-8232-6722</a>
- ResearcherID: A-5790-2016<br>
Researchgate: <a href="http://www.researchgate.net/profile/Alexandre_Santos10" rel="noreferrer" target="_blank">www.researchgate.net/profile/A<wbr>lexandre_Santos10</a><br>
LinkedIn: <a href="http://br.linkedin.com/in/alexandre-dos-santos-87961635" rel="noreferrer" target="_blank">br.linkedin.com/in/alexandre-d<wbr>os-santos-87961635</a><br>
Mendeley:<a href="http://www.mendeley.com/profiles/alexandre-dos-santos6/" rel="noreferrer" target="_blank">www.mendeley.com/prof<wbr>iles/alexandre-dos-santos6/</a><br>
==============================<wbr>==============================<wbr>==========<br>
<br>
______________________________<wbr>_________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi<wbr>-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-g<wbr>uia</a>)
e fornea cdigo mnimo reproduzvel.</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="m_8510547872449408250gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div><font style="font-family:arial" size="2">##############################<wbr>##############################<wbr>###</font><br>
<span style="font-family:arial;font-size:small">##
</span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Jônatan
Dupont Tatsch</span></div>
<div><span style="font-family:arial;font-size:small">##
</span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Professor
do Departamento de Física</span></div>
<div><span style="font-size:small;font-family:arial">##
</span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Centro
de Ciências Exatas e Naturais (CCNE)</span><br>
</div>
<div><span style="font-size:small;font-family:arial">##
</span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Universidade
Federal de Santa Maria - UFSM</span></div>
<div><span style="font-family:arial;font-size:small">##
</span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Faixa
de Camobi, Prédio 13 - Campus UFSM - </span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Santa
Maria, RS, Brasil - 97105-900</span><br>
</div>
<div style="font-family:arial;font-size:small">## <span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Telefone:
<a href="tel:+55%2055%203301-2083" value="+555533012083" target="_blank">+55(55)33012083</a></span><br>
</div>
<div style="font-family:arial;font-size:small">## <span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px"><a href="http://www.ufsm.br/meteorologia" target="_blank">www.ufsm.br/meteorologia</a></span></div>
<div style="font-family:arial;font-size:small">##############################<wbr>##############################<wbr>###</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><font size="2" style="font-family:arial">###############################################################</font><br><span style="font-family:arial;font-size:small">## </span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Jônatan Dupont Tatsch</span></div><div><span style="font-family:arial;font-size:small">## </span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Professor do Departamento de Física</span></div><div><span style="font-size:small;font-family:arial">## </span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Centro de Ciências Exatas e Naturais (CCNE)</span><br></div><div><span style="font-size:small;font-family:arial">## </span><span style="color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10.909090995788574px;line-height:12.997159004211426px;text-align:center;background-color:rgb(239,239,239)">Universidade Federal de Santa Maria - UFSM</span></div><div><span style="font-family:arial;font-size:small">## </span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Faixa de Camobi, Prédio 13 - Campus UFSM - </span><span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Santa Maria, RS, Brasil - 97105-900</span><br></div><div style="font-family:arial;font-size:small">## <span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px">Telefone: +55(55)33012083</span><br></div><div style="font-family:arial;font-size:small">## <span style="font-size:11px;text-align:center;background-color:rgb(239,239,239);color:rgb(150,150,150);font-family:Verdana,Arial,Helvetica,sans-serif;line-height:13px"><a href="http://www.ufsm.br/meteorologia" target="_blank">www.ufsm.br/meteorologia</a></span></div><div style="font-family:arial;font-size:small">###############################################################</div></div></div></div></div></div></div>
</div>