I tried to use SearchCursor(points, fields=fieldname) but I get this error:
TypeError: SearchCursor() got an unexpected keyword argument 'fields'
I'm not sure why this doesn't work.
# Local variables: points = arcpy.MakeFeatureLayer_management("C:\\alltogether.shp") homebase_shp = arcpy.MakeFeatureLayer_management("C:\\homebase.shp") fieldname = "Device" Device = arcpy.AddFieldDelimiters(points, fieldname) delimitedfield = arcpy.AddFieldDelimiters(points, fieldname) devices = set([row.getValue(fieldname) for row in arcpy.SearchCursor(points)]) for i in devices: attr_sel = arcpy.SelectLayerByAttribute_management(points,"NEW_SELECTION", delimitedfield + " = " + str(i)) totalpts = arcpy.GetCount_management(attr_sel) # Process: Select Layer By Location inside_sel = arcpy.SelectLayerByLocation_management(attr_sel, "WITHIN", homebase_shp, "", "SUBSET_SELECTION") insidepts = arcpy.GetCount_management(inside_sel) print "device %d has %d total points and %d inside the base" % (int(i),int(totalpts),int(insidepts))
a comment I saw earlier suggested doing it with fields=
Since you are only interested in one field, for better performance I would specify the >optional fields argument, e.g. myList = set([row.getValue(fldName) for row in >arcpy.SearchCursor(fcName, fields=fldName)]) – blah238 Jan 29 '12 at 1:03