hi, I'm simply trying to take a bunch of rasters in a directory and process each of them in my "for" loop. The first thing I need to do is project it. For some mysterious reason, the code goes through the loop the first time and processes the first raster fine, but I get an exception on the second raster (second loop iteration) on the ProjectRaster line (line 22) with the error "Undefined coordinate system for input dataset". All the rasters have the same defined coordinate system, and this happens no matter what rasters are in the list. It does the first one just fine, but when it loops back again to do the second one, I get the error. I can see it is reading the file list properly by looking at the string values it is using so no idea what the problem is. Here's the relevant code, thanks for any help!
<SPAN class="comment token"># Import necessary modules</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> glob<SPAN class="punctuation token">,</SPAN> os
<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>
os<SPAN class="punctuation token">.</SPAN>chdir<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"I:/SCHISM_project/HPC/input"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"I:/SCHISM_project/HPC/output"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="keyword token">for</SPAN> originalElevationRasterString <SPAN class="keyword token">in</SPAN> glob<SPAN class="punctuation token">.</SPAN>glob<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*.tif"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
rasterTimeString <SPAN class="operator token">=</SPAN> originalElevationRasterString<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">23</SPAN><SPAN class="punctuation token">]</SPAN>
originalElevationRasterBaseString <SPAN class="operator token">=</SPAN> originalElevationRasterString<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">23</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Project surface water elevation from Geographic to UTM</SPAN>
UTMProjection <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">(</SPAN><SPAN class="number token">26918</SPAN><SPAN class="punctuation token">)</SPAN>
originalElevationRasterUTMString <SPAN class="operator token">=</SPAN> originalElevationRasterBaseString <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_UTM.tif"</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Projecting water elevation to UTM..."</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>ProjectRaster_management<SPAN class="punctuation token">(</SPAN>originalElevationRasterString<SPAN class="punctuation token">,</SPAN> originalElevationRasterUTMString<SPAN class="punctuation token">,</SPAN> UTMProjection<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>