<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div class="post-text" itemprop="text">
<p>I need to get the value of a pixel (I have coordinates for this pixels) and its 8 surrounding pixel from the pixel/point. I am working with NetCDF files. I am working with R.</p>
<p>This is my code till now:</p>
<p>nc <- nc_open(file, readunlim=FALSE)</p>
<p>mylon <- ncvar_get(nc,"lon")<br/>
mylat <- ncvar_get(nc,"lat")</p>
<p>my coordinates in real-world: lat 52.5935 lon 18.4467</p>
<p>lat.coor <-mylat[which.min(abs(mylat-52.5935))]<br/>
lon.coor <- mylon[which.min(abs(mylon-18.4467))]</p>
<p>var <- nc[lon.coor, lat.coor, ]</p>
<p>In var are the values for my point. But I also need the values of the 8 surrounding pixels to get an average.</p>
<p> </p>
<p>Thanks.</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
</div></div></body></html>