I am trying to write a script in arcpy that checks to see if elevation values in a point file are found in a dictionary, and if they are to produce a new point file with just those entries. Sounds simple enough, but for some reason SelectByAttributes keeps returning the full dataset and not selecting properly. Further, this runs so slowly that I'm convinced there's a quicker way to do this, perhaps by making an array and writing a new point file with InsertCursor. Here's a snippet of my dysfunctional code:
import arcpy, collections
#transects_pts is a point shpfile with fields ID and elev
transect_pts = r'C:\transect_pts.shp'
inputRows = arcpy.SearchCursor(transect_pts,'','','ID; elev','ID')
layer = arcpy.MakeLayer_management(transects_pts,"tlayer")
#tdict is a default dict containing {ID: [elev1,elev2,elev3]}
for row in inputRows:
for m in tdict:
if row.elev in tdict[m]:
arcpy.SelectLayerByAttribute_management(layer,"ADD_TO_SELECTION")
arcpy.CopyFeatures_management(layer,"new_transect_pts")
If anyone has some insight, or a better way to do this, please help me!