<div dir="ltr">
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Colegas do R-br,</span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""> </span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Tenho a
seguinte questão:</span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""> </span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Estou
trabalhando com um grid de 0.1 x 0.1 grau de latitude e longitude onde quero
inserir a variável </span><span style="font-size:12pt;font-family:Courier">vento</span><span style="font-size:12pt;font-family:"Times New Roman","serif"">. No entanto a resolução do vento
é de 0.25 x 0.25 graus.</span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Os dados
estão armazenados aqui:</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><a href="http://www.datafilehost.com/d/693635d4">http://www.datafilehost.com/d/693635d4</a><br>
<br>
<a href="http://www.datafilehost.com/d/ee24730c">http://www.datafilehost.com/d/ee24730c</a></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">vento
<- read.csv('ascat.data.csv', header = TRUE)</span><span style="font-size:12pt;font-family:"Times New Roman","serif""></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">str(vento)</span><span style="font-size:12pt;font-family:"Times New Roman","serif""></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">grid
<- read.csv('grid.data.csv', header = TRUE)</span><span style="font-size:12pt;font-family:"Times New Roman","serif""></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">str(grid)</span></p><p class="MsoNormal" style="line-height:normal"><br><span style="font-size:12pt;font-family:Courier"></span><span style="font-size:12pt;font-family:"Times New Roman","serif""></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">#Quando
faço um </span><span style="font-size:12pt;font-family:Courier">merge()</span><span style="font-size:12pt;font-family:"Times New Roman","serif""> dos dois dataframes, obviamente
meus valores de </span><span style="font-size:12pt;font-family:"Times New Roman","serif""><span style="font-size:12pt;line-height:115%;font-family:Courier">#vento$media</span><span style="font-size:12pt;line-height:115%;font-family:"Times New Roman","serif""> </span> aparecem como NA pois não há nenhuma
correspondência entre as #coordenadas do grid e de vento.</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">dmerge
<- merge(grid, vento, by = c('lon', 'lat'), all.x = TRUE)</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier"><br></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Porém, eu
gostaria de obter valores de vento, por exemplo, entre latitudes</span><span style="font-size:12pt"> </span><span style="font-size:12pt;font-family:"Times New Roman","serif"">de</span><span style="font-size:12pt"> </span><span style="font-size:12pt;font-family:Courier">-22.625</span><span style="font-size:12pt;font-family:"Times New Roman","serif""> e </span><span style="font-size:12pt;font-family:Courier">-22.375</span><span style="font-size:12pt;font-family:"Times New Roman","serif""> na mesma escala do grid: </span><span style="font-size:12pt;font-family:Courier">-22.6, -22.5, -22.4</span><span style="font-size:12pt;font-family:"Times New Roman","serif"">, etc. E o mesmo para longitude.</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Tentei utilizar a </span><span style="font-size:12pt;font-family:Courier">scales::rescale()</span><span style="font-size:12pt;font-family:"Times New Roman","serif"">, mas consegui mudar apenas os mínimos e máximos das coordenadas:</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">#</span><span style="font-size:12pt;font-family:Courier">install.packages('scales', dependencies = TRUE)</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">library(scales)</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier"><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">vento$lon.r <- rescale(vento$lon, to = range(grid$lon))<br>vento$lon.r</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier"><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:Courier">vento$lat.r <- rescale(vento$lat, to = range(grid$lat))<br>vento$lat.r<br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p>
<p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Então,
creio que eu tenho dois problemas: o primeiro é obter as coordenadas de vento
na mesma escala que as do grid; segundo é interpolar </span><span style="font-size:12pt;font-family:Courier">vento$media</span><span style="font-size:12pt;font-family:"Times New Roman","serif""> para substituir os NAs, que correspondem a quase
metade do total de valores. <br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Agradeço se algum colega tiver alguma dica.</span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif""><br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Obrigada,<br></span></p><p class="MsoNormal" style="line-height:normal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">Heloise.<br></span></p>
</div>