AnsweredAssumed Answered

Extract By Mask Loop Crashing

Question asked by rralbritton on Oct 31, 2013
Latest reply on Apr 3, 2014 by mbs7038
My script keeps crashing, and I'm not sure why. No error messages are being printed, the program just quits.

import arcpy, os, shutil, datetime from arcpy import env from arcpy.sa import*  def outName(input,post="_Output"):     """Returns output name."""     outName=os.path.basename(input).split(".")[0]+post     return outName  #set workspaces arcpy.env.workspace = "C:\\TNC_GIS_Projects\\Surf_City" #arcpy.GetParameterAsText(0)  outputWorkspace = "C:\\TNC_GIS_Projects\\Surf_City\\Output_Folder" #arcpy.GetParameterAsText(1) arcpy.env.overwriteOutput = True  #Check out the ArcGIS 3D Analyst extension license arcpy.CheckOutExtension("3D") arcpy.CheckOutExtension("Spatial")  #Variables ObsPts = "C:\\TNC_GIS_Projects\\Surf_City\\Projected_Data\\Test_Points.shp" #arcpy.GetParameterAsText(2) footprint =  "C:\\TNC_GIS_Projects\\Surf_City\\Projected_Data\\Building_Footprints.shp" #arcpy.GetParameterAsText(3)  Elevation = "C:\\TNC_GIS_Projects\\Surf_City\\Projected_Data\\new_2010" #arcpy.GetParameterAsText(4) BareElevation = "C:\\TNC_GIS_Projects\\Surf_City\\Projected_Data\\baregrnd" #arcpy.GetParameterAsText(5) Ocean = "C:\\TNC_GIS_Projects\\Surf_City\\Projected_Data\\AtlanticOcean.shp" #arcpy.GetParameterAsText(6) FloorField = "FLOORS" #arcpy.GetParameterAsText(7)  Year = "2010" #arcpy.GetParameterAsText(8)  #Set analysis extent to elevation raster arcpy.env.extent = Elevation arcpy.env.cellSize = Elevation  #Create a temp folder to hold intermediate files. #Some of these folders will be deleted after the analysis has runs successfuly. IntermediateFiles = outputWorkspace+"/IntermediateFiles_"+Year Final_Floor_Viewsheds = outputWorkspace+"/Final_Viewsheds_"+Year SummaryTables = outputWorkspace+"/Summary_Tables_"+Year ElevAvgTables=outputWorkspace+"/ElevAvg_Tables_"+Year  if not os.path.exists(IntermediateFiles): os.makedirs(IntermediateFiles) if not os.path.exists(Final_Floor_Viewsheds) : os.makedirs(Final_Floor_Viewsheds) if not os.path.exists(SummaryTables) : os.makedirs(SummaryTables) if not os.path.exists(ElevAvgTables): os.makedirs(ElevAvgTables)  #Create Featue Layers arcpy.SetProgressorLabel("Creating feature layers") PointsFL = outName(ObsPts,"_Lyr") footprintFL = outName(footprint,"_Lyr") arcpy.MakeFeatureLayer_management(ObsPts, PointsFL) arcpy.MakeFeatureLayer_management(footprint,footprintFL)  RangeCount = int(arcpy.GetCount_management(PointsFL).getOutput(0))      arcpy.CalculateField_management(PointsFL,"OFFSETA",10,"PYTHON_9.3") arcpy.AddMessage("Observation point heights have been set to "+str(10)+" ft.")      arcpy.AddMessage("Calculating viewshed for "+str(RangeCount)+" parcel, for floor number "+str(1))      for points in range (0,RangeCount):      try:                      FID = "FID=%s" % (points)          ##Get bare earth elevation of parcel         #extract parcel raster cells         arcpy.SelectLayerByAttribute_management(PointsFL,"NEW_SELECTION",FID)         print arcpy.GetMessages(), "\n\n"         arcpy.SelectLayerByLocation_management(footprintFL,"INTERSECT",PointsFL)         print arcpy.GetMessages(), "\n\n"         outExtractByMask = ExtractByMask(BareElevation,footprintFL)         outExtractByMask.save(IntermediateFiles+"\\fp_1")#+str(1)+"_"+str(FID)[4:])         print arcpy.GetMessages(), "\n\n"              except:          print arcpy.GetMessages()  print "done" 

Outcomes