This post made me go back to my code and think about this issue again and I think I've come up with a simple solution that works. I've gotten IsNull to work in the past so I think the problem is actually caused because I'm casting the output path of a PolygonToRaster function to a raster by simply doing polyRaster = Raster(outputPath) - which should work and generally does for casting path strings to Raster objects.If I instead make a raster layer using MakeRasterLayer_management and use that layer name as the input to my subsequent operations (Con in this case), it works without issue.So my code went from this:arcpy.PolygonToRaster_conversion(inPoly,valueField,outputPath,"CELL_CENTER","#",arcpy.env.cellSize)polyRaster = Raster(outputPath)output = Con(IsNull(polyRaster),0,polyRaster) ##Returns 999998: Unexepected Errorto this:arcpy.PolygonToRaster_conversion(inPoly,valueField,outputPath,"CELL_CENTER","#",arcpy.env.cellSize)arcpy.MakeRasterLayer_management(outputPath,"polyRaster")output = Con(IsNull("polyRaster"),0,"polyRaster")So the solution works for me but there must be a bug in the type casting or something...
RuntimeError: ERROR 000732: Input Raster: Dataset d:\Users\MICHAL~1.THI\AppData\Local\Temp\x923a0602_2133_4e68_bd44_b285094f1537y0.afr does not exist or is not supported
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.