title: How to implement equation amnog two raster grid cells ( Calculate average wind using u and v wind components on each grid cells)
body: <p>I have two raster stack files <code>ur</code> and <code>vr</code> with u and v component of wind speed respectively.
  How can I calculate average wind speed and direction in each grid cell ?
  I know I can calculate wind direction using following equation</p>
  
  <pre><code>windir&lt;-calc(atan2(vwind, uwind) * 360/2/pi) + 180 
  </code></pre>
  
  <p>and average wind using </p>
  
  <pre><code>winav&lt;- ((mean.u^2 + mean.v^2)^0.5)
  </code></pre>
  
  <p>My problem is how can I implement these equations on each grid cells of <code>ur</code> and <code>vr</code>
   I referred to <a href="https://stackoverflow.com/questions/21484558/how-to-calculate-wind-direction-from-u-and-v-wind-components-in-r">this question</a> and other links however still stocked in this calculation.</p>