0

Check this straightforward code that exports the subset of a shapefile (path_of_shp) using where_clause:

where_clause = '"new" = 1'
arcpy.MakeFeatureLayer_management(path_of_shp, "feature")
arcpy.SelectLayerByAttribute_management("feature", "NEW_SELECTION", where_clause)
arcpy.Copy_management("feature", "C:/GIS/output.shp")

This gives an error:

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Data Element. Failed to execute (Copy).

2

Use the Copy Features tool instead of the Copy tool. The Copy tool wants physical items, not a "virtual" item like you get from Make Feature Layer.

1

Instead of using four lines of code to do this, you could use just two:

where_clause = '"new" = 1'
arcpy.Select_analysis(path_of_shp, "C:/GIS/output.shp", where_clause)

or even just one (depending on whether you want your where_clause value to be re-used later in your code):

arcpy.Select_analysis(path_of_shp, "C:/GIS/output.shp", "new = 1")

Note that I simplified the where_clause in the one-liner because double-quotes around the field name have not been needed for quite a few versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.