I have a feature class. I want to copy the FC and use a WHERE clause to limit the rows copied. I tried using the CopyFeatures_management but it throws an error on the
Here's the code:
import arcpy arcpy.env.workspace = 'C:/.../localFile.gdb' inFC = 'inputFeatureClassName' outFC = 'tmp_JUNK' arcpy.CopyFeatures_management(inFC, outFC, '"FIELD_NAME" = "VALUE"')
The error thrown:
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of | DEFAULTS | TEXT_UTF16 | MAX_FILE_SIZE_4GB | MAX_FILE_SIZE_256TB | GEOMETRY_OUTOFLINE | BLOB_OUTOFLINE | GEOMETRY_AND_BLOB_OUTOFLINE | TERRAIN_DEFAULTS | MOSAICDATASET_DEFAULTS | MOSAICDATASET_INLINE. Failed to execute (CopyFeatures).
Any ideas what I'm doing wrong and how to fix it?
Update #1 - This code works but I question whether it's really the best approach. If I understand this, I create a feature layer, perform the selection on the feature layer, and then write the selection to a new feature class. Is that correct? Is this the most efficient approach?
# Import system modules import arcpy from arcpy import env # Set overwrite option arcpy.env.overwriteOutput = True # Put in error trapping in case an error occurs when running tool try: # Make a layer from the feature class arcpy.MakeFeatureLayer_management("C:/.../localFile.gdb/tmp_FeatureClass","tmpOMG") arcpy.SelectLayerByAttribute_management("tmpOMG", "NEW_SELECTION", """"FIELD_NAME" = 'VALUE'""") # Write the selected features to a new featureclass arcpy.CopyFeatures_management("tmpOMG", "C:/.../localFile.gdb/tmpOutFromLayer") except: print arcpy.GetMessages()
source: ArcGIS Help