Hi,
I'm trying to run Mean annual cell statistics for groups of monthly rasters.
The output I'm getting is the same as the last raster in the list ("camp_t_srf_sep" in this example) so i assume the script is not actually iterating through all rasters.
Any help will be greatly appreciate it.
<SPAN class="comment token"># Example of list of rasters:</SPAN>
<SPAN class="comment token"># camp_t_srf_apr</SPAN>
<SPAN class="comment token"># camp_t_srf_aug</SPAN>
<SPAN class="comment token"># camp_t_srf_dec</SPAN>
<SPAN class="comment token"># camp_t_srf_feb</SPAN>
<SPAN class="comment token"># camp_t_srf_jan</SPAN>
<SPAN class="comment token"># camp_t_srf_jul</SPAN>
<SPAN class="comment token"># camp_t_srf_jun</SPAN>
<SPAN class="comment token"># camp_t_srf_mar</SPAN>
<SPAN class="comment token"># camp_t_srf_may</SPAN>
<SPAN class="comment token"># camp_t_srf_nov</SPAN>
<SPAN class="comment token"># camp_t_srf_oct</SPAN>
<SPAN class="comment token"># camp_t_srf_sep</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">from</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>sa <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckOutExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Spatial"</SPAN><SPAN class="punctuation token">)</SPAN>
env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
env<SPAN class="punctuation token">.</SPAN>extent <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Extent<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">180.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">90.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">180.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">90.0</SPAN><SPAN class="punctuation token">)</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
StageAge <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
rasterlist <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListRasters<SPAN class="punctuation token">(</SPAN>StageAge <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_*"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> raster <SPAN class="keyword token">in</SPAN> rasterlist<SPAN class="punctuation token">:</SPAN>
output_mean <SPAN class="operator token">=</SPAN> CellStatistics<SPAN class="punctuation token">(</SPAN>raster<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MEAN"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DATA"</SPAN><SPAN class="punctuation token">)</SPAN>
output_mean<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> raster<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">11</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"ann"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>