I am working on a very long Python model that assesses habitat loss associated with development in Sage Grouse habitat in Montana.
Part of this script combines a 32-bit-float rasters (values between 0-1) with a "dummy" extent raster (with values all 1) via Mosaic to New Raster using the "Minimum" mosaic method. This is done to create standardized rasters for each type of disturbance that are used later for further raster math. When performing this step with larger projects with a small pixel size (3.75 meters is our standard) Python.exe stops running and the script dies. I don't get a specific error message, which leads me to believe it is some kind of memory issue that is beyond my knowledge. Any insight would be useful.
The top section of this section of code contains the 'if' statements where python crashes (again, this only occurs when the "PixelSize" variable that you see in the MosaicToNewRaster tuple is set earlier in the script to values below roughly 30 meters):
if arcpy.Exists(RoadOutRastCalc):
arcpy.MosaicToNewRaster_management([RoadOutRastCalc, extentMergeRaster], HQTOutputgdb, "DummyRoadsOps", "", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM" )
if arcpy.Exists(PlineOutRastCalc):
arcpy.MosaicToNewRaster_management([PlineOutRastCalc, extentMergeRaster], HQTOutputgdb, "DummyPowerOps","", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM" )
if arcpy.Exists(GravOutRastCalc):
arcpy.MosaicToNewRaster_management([GravOutRastCalc, extentMergeRaster], HQTOutputgdb, "DummyGravEtAlOps", "", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM")
if arcpy.Exists(TallRastCalc):
arcpy.MosaicToNewRaster_management([TallRastCalc, extentMergeRaster], HQTOutputgdb, "DummyTallOps", "", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM")
if arcpy.Exists(AgMineRastCalc):
arcpy.MosaicToNewRaster_management([AgMineRastCalc, extentMergeRaster], HQTOutputgdb, "DummyAgMine", "", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM")
if arcpy.Exists(SubsRastCalc):
arcpy.MosaicToNewRaster_management([SubsRastCalc, extentMergeRaster], HQTOutputgdb, "DummySubs", "", "32_BIT_FLOAT", PixelSize, "1", "MINIMUM")
##Multiply Rasters Together Using List
RasterList = [DummyGravEtAl, DummyPower, DummyRoads, DummyTall, DummyAgMine, DummySubs]
MultiplierList =[]
for i in RasterList:
if arcpy.Exists(i):
MultiplierList.append(i)
print(MultiplierList)
arcpy.AddMessage(MultiplierList)
if len(MultiplierList) == 1:
OperationsImpact = (Raster(MultiplierList[0]) * (DummyHQT))
elif len(MultiplierList) == 2:
OperationsImpact = (Raster(MultiplierList[0]) * Raster(MultiplierList[1]) * (DummyHQT))
elif len(MultiplierList) == 3:
OperationsImpact = (Raster(MultiplierList[0]) * Raster(MultiplierList[1]) * Raster(MultiplierList[2]) * (DummyHQT))
elif len(MultiplierList) == 4:
OperationsImpact = (Raster(MultiplierList[0]) * Raster(MultiplierList[1]) * Raster(MultiplierList[2]) * Raster(MultiplierList[3]) * (DummyHQT))
elif len(MultiplierList) == 5:
OperationsImpact = (Raster(MultiplierList[0]) * Raster(MultiplierList[1]) * Raster(MultiplierList[2]) * Raster(MultiplierList[3]) * Raster(MultiplierList[4]) * (DummyHQT))
elif len(MultiplierList) == 6:
OperationsImpact = (Raster(MultiplierList[0]) * Raster(MultiplierList[1]) * Raster(MultiplierList[2]) * Raster(MultiplierList[3]) * Raster(MultiplierList[4]) * Raster(MultiplierList[5]) * (DummyHQT))
Solved! Go to Solution.
for anyone reading, I ended up using decimal rasters rather than float. I also wrote them to a folder directory as TIFFS rather than geodatabase rasters. This seemed to work a lot better and alleviated the crashing. Not sure why TIFF versus gdb rasters is less crashy, but I'll take it!
You might want to try multiplying your float rasters by some amount (e.g. 100, 1000, etc.) and working with integer rasters. They are much easier on your system.
Yes, I may try that. I was hoping there was something else I was missing before I dove into that work-around. It's going to require some significant editing to make them integers for this step, and there are four other spots in the script that will require similar edits if I go that route. Thanks for the input!
for anyone reading, I ended up using decimal rasters rather than float. I also wrote them to a folder directory as TIFFS rather than geodatabase rasters. This seemed to work a lot better and alleviated the crashing. Not sure why TIFF versus gdb rasters is less crashy, but I'll take it!
I am working with the same script as the original poster and the crashing issue came up again. I have no idea why its crashing as well only that it began doing so after an update from Dec. 2019 was applied. I changed the tif outputs to png and it works. ESRI grids were still not working.