This is basically a repost of a previous question. I thought I resolved it but I did not.
In one large script, I am generating a floating point TIF raster through a couple of raster operations. I do this multiple times to generate multiple TIF floating point rasters. I then create a file geodatabase and try to copy these TIF rasters into that file geodatabase with RasterToGeodatabase. Basically the output rasters are becoming the input of the RasterToGeodatabase. But the copied rasters in the file geodatabase are corrupted - no cell size or extent or range, and nothing is displayed. .
If I close and re-open the Python session and just create the file geodatabase and use the RasterToGeodatabase command (without running the whole script), those TIF rasters copy just fine into the file geodatabase.
So I'm thinking it has something to do with the larger Python script locking on to the TIF rasters that were just created in the script, so I can't operate on them. Thanks for any help..
outFilePath <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/SCHISM_project/output_test_FGDB"</SPAN>
outFile <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Final_"</SPAN> <SPAN class="operator token">+</SPAN> rasterTimeString <SPAN class="operator token">+</SPAN> <SPAN class="string token">".tif"</SPAN>
<SPAN class="comment token"># Generate final rasters by mosaicing rasters and then Con to extract non-zero values</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MosaicToNewRaster_management<SPAN class="punctuation token">(</SPAN>rastersListString<SPAN class="punctuation token">,</SPAN> outFilePath<SPAN class="punctuation token">,</SPAN> outFile<SPAN class="punctuation token">,</SPAN> "<SPAN class="comment token">#", "32_BIT_FLOAT", "#", "1", "LAST", "FIRST")</SPAN>
testMosaic <SPAN class="operator token">=</SPAN> Raster<SPAN class="punctuation token">(</SPAN>outFilePath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/"</SPAN> <SPAN class="operator token">+</SPAN> outFile<SPAN class="punctuation token">)</SPAN>
testMosaicCon <SPAN class="operator token">=</SPAN> Con<SPAN class="punctuation token">(</SPAN>testMosaic <SPAN class="operator token"><></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> testMosaic<SPAN class="punctuation token">)</SPAN>
testMosaicCon<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:/SCHISM_project/output_test_FGDB/Final_"</SPAN> <SPAN class="operator token">+</SPAN> rasterTimeString <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_Con.tif"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Create file geodatabase</SPAN>
todaysDateString <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>date<SPAN class="punctuation token">.</SPAN>today<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>strftime<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"%Y%m%d"</SPAN><SPAN class="punctuation token">)</SPAN>
out_folder_path <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Y:/SCHISM_Data"</SPAN>
out_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"SCHISM_Data_"</SPAN> <SPAN class="operator token">+</SPAN> todaysDateString <SPAN class="operator token">+</SPAN> <SPAN class="string token">".gdb"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CreateFileGDB_management<SPAN class="punctuation token">(</SPAN>out_folder_path<SPAN class="punctuation token">,</SPAN> out_name<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Create list of rasters</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/SCHISM_project/output_test_FGDB"</SPAN>
rasterList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListRasters<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*Con*"</SPAN><SPAN class="punctuation token">)</SPAN>
rasterPathList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> eachRaster <SPAN class="keyword token">in</SPAN> rasterList<SPAN class="punctuation token">:</SPAN>
rasterPathList<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>eachRaster<SPAN class="punctuation token">)</SPAN>
finalRasterPathList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">";"</SPAN><SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> rasterPathList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Copy final rasters into file geodatabase on mobjack..."</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>RasterToGeodatabase_conversion<SPAN class="punctuation token">(</SPAN>finalRasterPathList<SPAN class="punctuation token">,</SPAN> out_folder_path <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/"</SPAN> <SPAN class="operator token">+</SPAN> out_name<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></SPAN><SPAN></SPAN></SPAN>