# Set local environment: Path = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\" Working = Path + "nexrad_Irene_Working" arcpy.env.workspace = Working arcpy.env.overwriteOutput = 1 # Set local variables: NEXRAD2grid = arcpy.ListFeatureClasses() HRAP_Projection = "PROJCS['HRAP_Projection',GEOGCS['HRAP_GCS',DATUM['D_HRAP',SPHEROID['HRAP_Sphere',6371200.0,0.0]],PRIMEM['<custom>',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Standard_Parallel_1',60.0],UNIT['HRAP_Grid',4762.5]]" arcpy.env.outputCoordinateSystem = HRAP_Projection arcpy.env.extent = "-236 -1476 661 -806" arcpy.env.cellSize = "1" for fc in NEXRAD2grid: desc = arcpy.Describe(fc) filename = desc.name NEXRADgrids = filename[:-4] arcpy.PointToRaster_conversion(fc, "Globvalue", NEXRADgrids, "MAXIMUM", "NONE", "1") #execute point to raster print NEXRADgrids
When I run my script, Python crashes with no helpful error message.
import sys import traceback import arcpy try: # Set local environment: Path = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\" Working = Path + "nexrad_Irene_Working" arcpy.env.workspace = Working arcpy.env.overwriteOutput = 1 # Set local variables: NEXRAD2grid = arcpy.ListFeatureClasses() HRAP_Projection = "PROJCS['HRAP_Projection',GEOGCS['HRAP_GCS',DATUM['D_HRAP',SPHEROID['HRAP_Sphere',6371200.0,0.0]],PRIMEM['<custom>',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Standard_Parallel_1',60.0],UNIT['HRAP_Grid',4762.5]]" arcpy.env.outputCoordinateSystem = HRAP_Projection arcpy.env.extent = "-236 -1476 661 -806" arcpy.env.cellSize = "1" for fc in NEXRAD2grid: desc = arcpy.Describe(fc) filename = desc.name NEXRADgrids = filename[:-4] arcpy.PointToRaster_conversion(fc, "Globvalue", NEXRADgrids, "MAXIMUM", "NONE", "1") #execute point to raster print NEXRADgrids except: # print python errors tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] print tbinfo # print geprocessing errors messages (if any) print arcpy.GetMessages(2)
I don't know the exact issue with your script, but are you running this within ArcGIS or as a stand alone python script?
If it's stand alone, my next question would be which python handler are you using?
I personally use IDLE, and when I've had trouble with it I use the debugger to step through each line to find where it's causing problems.
If you're unsure of using the debugger there's a plethora of info on it by searching for it. It may not solve the exact problem, but at the very least, it should 100% confirm the exact point the script is failing.
I suggest looking into the online help examples on exception handling -- these techniques can really help - for example, you can print which line the script failed on.
Arc 10 Help: Error handling with Python
Here's a try/except wrapped around your code that will do that:
import sys import traceback import arcpy try: # Set local environment: Path = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\" Working = Path + "nexrad_Irene_Working" arcpy.env.workspace = Working arcpy.env.overwriteOutput = 1 # Set local variables: NEXRAD2grid = arcpy.ListFeatureClasses() HRAP_Projection = "PROJCS['HRAP_Projection',GEOGCS['HRAP_GCS',DATUM['D_HRAP',SPHEROID['HRAP_Sphere',6371200.0,0.0]],PRIMEM['<custom>',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Standard_Parallel_1',60.0],UNIT['HRAP_Grid',4762.5]]" arcpy.env.outputCoordinateSystem = HRAP_Projection arcpy.env.extent = "-236 -1476 661 -806" arcpy.env.cellSize = "1" for fc in NEXRAD2grid: desc = arcpy.Describe(fc) filename = desc.name NEXRADgrids = filename[:-4] arcpy.PointToRaster_conversion(fc, "Globvalue", NEXRADgrids, "MAXIMUM", "NONE", "1") #execute point to raster print NEXRADgrids except: # print python errors tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] print tbinfo # print geprocessing errors messages (if any) print arcpy.GetMessages(2)
PS Please tags when posting Python code.
Will the debugger only help me identify where the problem is or also what the problem might be?
When I entered your code, Python crashed.
#Set Variables inWS = r"C:\My_Stuff\ConvertPTtoRaster\SHP" # In workspace outWS = r"C:\My_Stuff\ConvertPTtoRaster\Output" # Out workspace arcpy.env.workspace = inWS arcpy.env.overwriteOutput = 1 arcpy.env.extent = "2470500 7661500 2477000 7666800" arcpy.env.cellSize = 25 ptFeatures = list() ptFeatures = arcpy.ListFeatureClasses("","Point") #Only use points features for fc in ptFeatures: fName = arcpy.Describe(fc).basename arcpy.PointToRaster_conversion(fc,"Z",outWS + "\\" + fName,"MAXIMUM","",25)
inWS = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\nexrad_Irene_Working" # In workspace outWS = inWS # Out workspace arcpy.env.workspace = inWS arcpy.env.overwriteOutput = 1 arcpy.env.extent = "-236 -1476 661 -806" arcpy.env.cellSize = 1 ptFeatures = list() ptFeatures = arcpy.ListFeatureClasses("","Point") #Only use points features for fc in ptFeatures: fName = arcpy.Describe(fc).basename arcpy.PointToRaster_conversion(fc,"Globvalue",outWS + "\\" + fName,"MAXIMUM","NONE",1)