<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 18/09/2017 20:01, Heloíse Pavanato
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPw23dG2Y5FPAAAnxtnZWMCgWjkeNuL5x4ADhktsco8Tg4XF0A@mail.gmail.com">não
achei a função <span style="font-family:verdana,sans-serif">nearest.pixel()</span>
no <span style="font-family:verdana,sans-serif">spatstat</span>.
Seria <span style="font-family:verdana,sans-serif">nearest.raster.point()</span>?
</blockquote>
Veja esse exemplo:<br>
<br>
<br>
library(spatstat)<br>
<br>
### simula uma imagem qualquer<br>
x0 <- seq(0, 7, 0.1)<br>
y0 <- seq(0, 10, 0.1)<br>
grid.z <- im(t(outer(x0, y0, function(x,y)<br>
cos(x) - sin(y-2))), x0, y0)<br>
<br>
### visualiza<br>
plot(grid.z, x0, y0) <br>
contour(x0, y0, t(grid.z$v), add=TRUE)<br>
<br>
### simula alguns pontos<br>
x.loc <- runif(5, 0, 7)<br>
y.loc <- runif(5, 0, 10)<br>
<br>
### extrai valores dos pixels proximos<br>
id.r.c <- nearest.pixel(x.loc, y.loc, grid.z)<br>
str(id.r.c)<br>
<br>
### extrai os valores<br>
z <- grid.z[Reduce('cbind', id.r.c)] <br>
str(z)<br>
<br>
###junta<br>
cbind(x.loc, y.loc, z)<br>
<br>
### adiciona como texto<br>
text(x.loc, y.loc, format(z, dig=2))<br>
<br>
</body>
</html>