4

I am using ArcGIS Desktop 10.5.

I have had this work for me before, so I am confused as to what problem I am -running into now. When making a selection to copy to a new dataset in Arcpy, -here is the important part of the code:

sortoutput = 'c:/Users/srcha/Desktop/Cluster_Analysis/output/Ld_Playas_extracted1_sorted.shp'
sortedftr = 'C:/Users/srcha/Desktop/Cluster_Analysis/output/Ld_Play_extra_sort_ftr.shp'
arcpy.MakeFeatureLayer_management(sortoutput,sortedftr)
arcpy.SelectLayerByAttribute_management(sortedftr, selection_type="NEW_SELECTION", where_clause='"AREA_ADJ" >=0.07957')

This yields the following error:

ExecuteError: Failed to execute. Parameters are not valid. Error 000732: Layer Name of Table View: data set C:/Users/srcha/Desktop/Cluster_Analysis/output/Ld_Play_extra_sort_ftr.shp does not exist or is not supported

Failed to execute (SelectLayerByAttribute)

5

You cant create a feature layer on disk, it is stored in memory only.

Change:

sortedftr = 'C:/Users/srcha/Desktop/Cluster_Analysis/output/Ld_Play_extra_sort_ftr.shp'

To:

sortedftr = 'sortedftr_lyr'

After the selection if you can use Copy features to convert the layer to a shapefile on disk.

You dont actually need Select by attributes, this can be done with the where_clause of Make Feature Layer:

where_clause (Optional)

An SQL expression used to select a subset of features.

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.