# Developed by: David Bailey # Description: Providence Creek Watershed: land cover processing # import arcpy site-package and os module import arcpy, os # Set geoprocessing environment: # a) set the workspace environment aWS = r"C:\Thesis_Research\GIS\Prov_classification.gdb" arcpy.env.workspace = aWS # Set geoprocessing environment: # b) the overwriteOutput parameter controls whether tools will # automatically overwrite any existing output arcpy.env.overwriteOutput = True try: # Create query statements for each land cover type LIDAR_tree = '"grid_code" > \'3\'' LIDAR_shrub = '"grid_code" = \'2\' OR "grid_code" = \'3\'' LIDAR_ground = '"grid_code" <= \'1\'' aListLIDAR = [LIDAR_tree, LIDAR_shrub, LIDAR_ground] for item in aListLIDAR: arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", P303_layerL) arcpy.SelectLayerByAttribute_management(P303_layerL, "NEW_SELECTION", aListLIDAR) arcpy.CopyFeatures_management(P303_layerL, "P303_" + str(item)) del aListLIDAR del item del P303_layerL except: # Code to run when an error occured print "An ERROR Occured!" print "\n" + arcpy.GetMessages() else: # Message when there was no error print "\nNo Error occurred" # Script end message print "\nEnd of the script!"
I put the script in a code block - It is not telling me the error.
I am new to python, and I just threw this script together by reading other python scripts. Let me know if you need more info# Developed by: David Bailey # Description: Providence Creek Watershed: land cover processing # import arcpy site-package and os module import arcpy, os # Set geoprocessing environment: # a) set the workspace environment aWS = r"C:\Thesis_Research\GIS\Prov_classification.gdb" arcpy.env.workspace = aWS # Set geoprocessing environment: # b) the overwriteOutput parameter controls whether tools will # automatically overwrite any existing output arcpy.env.overwriteOutput = True try: # Create query statements for each land cover type LIDAR_tree = '"grid_code" > \'3\'' LIDAR_shrub = '"grid_code" = \'2\' OR "grid_code" = \'3\'' LIDAR_ground = '"grid_code" <= \'1\'' aListLIDAR = [LIDAR_tree, LIDAR_shrub, LIDAR_ground] for item in aListLIDAR: arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", P303_layerL) arcpy.SelectLayerByAttribute_management(P303_layerL, "NEW_SELECTION", aListLIDAR) arcpy.CopyFeatures_management(P303_layerL, "P303_" + str(item)) del aListLIDAR del item del P303_layerL except: # Code to run when an error occured print "An ERROR Occured!" print "\n" + arcpy.GetMessages() else: # Message when there was no error print "\nNo Error occurred" # Script end message print "\nEnd of the script!"
# Developed by: David Bailey # Description: Providence Creek Watershed: land cover processing # import arcpy site-package and os module import arcpy, os # Set geoprocessing environment: # a) set the workspace environment aWS = r"C:\Thesis_Research\GIS\Prov_classification.gdb" arcpy.env.workspace = aWS # Set geoprocessing environment: # b) the overwriteOutput parameter controls whether tools will # automatically overwrite any existing output arcpy.env.overwriteOutput = True try: # Create query statements for each land cover type LIDAR_tree = '"grid_code" > \'3\'' LIDAR_shrub = '"grid_code" = \'2\' OR "grid_code" = \'3\'' LIDAR_ground = '"grid_code" <= \'1\'' aListLIDAR = [LIDAR_tree, LIDAR_shrub, LIDAR_ground] layerName = ["tree","shrub","ground"] n = 0 for query in aListLIDAR: arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", "temp_layer", where_clause=query) arcpy.CopyFeatures_management("temp_layer", "P303_{0}_layer".format(layerName)) arcpy.Delete_management("temp_layer") n += 1 except: # Code to run when an error occured print "An ERROR Occured!" print "\n" + arcpy.GetMessages() # Script end message print "\nEnd of the script!"
In your arcpy.MakeFeatureLayer_management method, your outlayer is being written to a variable "P303_layerL" that was never declared anywhere, that would certainly throw an error.