eva01

Issues iterating over folder contents

Discussion created by eva01 on Feb 27, 2012
Latest reply on Feb 28, 2012 by eva01
I'm attempting to create new shapefiles / feature classes (either), but am having problems.  Executing the Python script gives me:

Executing: MakeFeatureLayer E:/Capstone/Keyed/ E_lyr # # #
Start Time: Mon Feb 27 19:32:41 2012
Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset E:/Capstone/Keyed/ does not exist or is not supported
Failed to execute (MakeFeatureLayer).
Failed at Mon Feb 27 19:32:41 2012 (Elapsed Time: 0.00 seconds)

Any help is appreciated!


# Name: ExtractFeaturesByLocationAndAttribute.py
# Description:  Extracts features to a new feature class based on a location and an attribute query.

# Import system modules
import arcpy
from arcpy import env

# Set overwrite option
arcpy.env.overwriteOutput = True

# Set High Selector
high = "E:/Capstone/Keyed/Capstone.gdb/high"
fcs = "E:/Capstone/Keyed/"

# Put in error trapping in case an error occurs when running tool
try:

   for fc in fcs:
       
       # Make a layer from the feature class
       arcpy.MakeFeatureLayer_management(fcs, fc + "_lyr")

       # Select zones in "High" opportunity areas
       arcpy.SelectLayerByLocation_management(fc + "_lyr", "HAVE_THEIR_CENTER_IN", high, "", "NEW_SELECTION")

       # Write the selected features to a new featureclass
       arcpy.CopyFeatures_management(fc + "_lyr", "E:/Capstone/Keyed/Capstone.gdb/" + fc[0:5] + "_high")

except:
   print arcpy.GetMessages()

Outcomes