From my previous post having trouble writing a raster from a viewshed. I have the viewshed raster writing correctly to my scratch DB, however as much as i try I can't get MakeRasterLayer_management to create a raster file either in the dataframe or to disk.
If I run this line of code from Python geoprocessing inside ArcMap the layer add correctly
running from a standalone script is does nothing. Here's a code snippet so you can see what's going on. Obviously lots of messages etc for me to see what's going on
Everything appears to work properly other than the MakeRasterLayer
Pretty frustrated at this point, I've tried all I can.
Thanks
If I run this line of code from Python geoprocessing inside ArcMap the layer add correctly
Code:
ping_layer = 'path to layer in the scratch gdb'
arcpy.MakeRasterLayer_management(Final_Viewshed,ping_layer,rQuery)Code:
# Set enviroment, frames and layers
arcpy.env.workspace
arcpy.env.scratchWorkspace
scratchdb = arcpy.env.scratchGDB
scratchfdr = arcpy.env.scratchFolder
arcpy.env.overwriteOutput = True
if arcpy.CheckOutExtension('Spatial'):
if arcpy.GetCount_management(inObserverFeatures) != 0:
arcpy.AddMessage('Ping count is {0}'.format(arcpy.GetCount_management(inObserverFeatures)))
outViewshed = Viewshed(clippedraster, inObserverFeatures, zFactor, useEarthCurvature, refractivityCoefficient)
Final_Viewshed ='{0}\Final_Viewshed_{1}'.format(scratchdb,timestamp)
outViewshed.save(Final_Viewshed)
rQuery = '{0} > 0'.format(arcpy.AddFieldDelimiters(outViewshed.name.title(),"Value"))
arcpy.AddMessage('Final_Viewshed_{0}'.format(Final_Viewshed))
if Final_Viewshed:
arcpy.AddMessage('Found {0}'.format(Final_Viewshed))
ping_layer = '{0}\PingLayer_{1}.lyr'.format(scratchfdr,timestamp)
arcpy.MakeRasterLayer_management(Final_Viewshed,ping_layer,rQuery)
arcpy.AddMessage('ping layer = {0}'.format(ping_layer))
else:
arcpy.AddMessage('Not there')Pretty frustrated at this point, I've tried all I can.
Thanks