title: How to extract and calculate the mean for certain region form rasters?
body: <p>I want to select small region in the first raster and calculate the spatial average for that region and do the same for the other 11 rasters. so will finally get 12 values. </p>
  
  <p>I tried this:</p>
  
  <pre><code>sami&lt;- list.files("C:\\New folder (3)", "*.envi", full.names = TRUE)
  saf=stack(sami)
  plot(saf, 1)   ## to select a region
  e &lt;- drawExtent()## I selected the region
  saf_test &lt;- crop(saf, e)
  </code></pre>
  
  <p>is this right to do so?</p>
  
  <p>Then how I calculate the spatial average for the selected region?and do the same for all other rasters.
  Thanks in advance.</p>