Problem copying TIF rasters into a file geodatabase

03-21-2018 08:06 AM
New Contributor III

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 = "C:/SCHISM_project/output_test_FGDB"
outFile = "Final_" + rasterTimeString + ".tif"

# Generate final rasters by mosaicing rasters and then Con to extract non-zero values
arcpy.MosaicToNewRaster_management(rastersListString, outFilePath, outFile, "#", "32_BIT_FLOAT", "#", "1", "LAST", "FIRST")
testMosaic = Raster(outFilePath + "/" + outFile)
testMosaicCon = Con(testMosaic <> 0, testMosaic)"C:/SCHISM_project/output_test_FGDB/Final_" + rasterTimeString + "_Con.tif")

# Create file geodatabase
todaysDateString ="%Y%m%d")
out_folder_path = "Y:/SCHISM_Data"
out_name = "SCHISM_Data_" + todaysDateString + ".gdb"
arcpy.CreateFileGDB_management(out_folder_path, out_name)

# Create list of rasters
arcpy.env.workspace = "C:/SCHISM_project/output_test_FGDB"
rasterList = arcpy.ListRasters("*Con*")

rasterPathList = []
for eachRaster in rasterList:

finalRasterPathList = (";".join((i for i in rasterPathList)))

# Copy final rasters into file geodatabase on mobjack..."
arcpy.RasterToGeodatabase_conversion(finalRasterPathList, out_folder_path + "/" + out_name)
0 Kudos
1 Reply
MVP Emeritus

...something to do with the larger Python script locking on to the TIF rasters...

Have you reversed the order by creating the geodatabase first, before processing any of the tiff files?

0 Kudos