0

I am a little bit confused with the "ADD_TO_SELECTION" possibility. I process a point layer. First, the idea was to process the points with the different GBAUPS attribute separately. And it worked like this:

periode_field = "GBAUPS"
valueList = []
rows = arcpy.SearchCursor(input_gws_layer)
for row in rows:
 valueList.append(row.getValue(periode_field))
uniqueSet = set(valueList)
uniqueList = list(uniqueSet)
uniqueList.sort()
print uniqueList
for period in uniqueList:
 period = int(period)
 bauperiod = arcpy.Select_analysis(input_gws_layer, "input_gws_layer_%i" % period, "GBAUPS = %i" % period)
 ...... and the processing ......

But I would like now to add continuously the points from the previous layers to the next one (first just one value of the attribute GBAUPS, then this one and the second one etc.) I've tried like this, but the result is exactly the same as in the previous case.

for period in uniqueList:
 period = int(period)
 # selection
 arcpy.MakeFeatureLayer_management(input_gws_layer, "input_gws_layer_lyr")
 arcpy.SelectLayerByAttribute_management("input_gws_layer_lyr", "ADD_TO_SELECTION", "GBAUPS = %i" % period)
 arcpy.CopyFeatures_management("input_gws_layer_lyr", "input_gws_layer_lyr_%i" % period)
 ...... and the processing ......

I am not sure if I do something wrong in the SelectLayerByAttribute_management or in the CopyFeatures_management.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 10, 2013 at 16:46

1 Answer 1

2

In your current code, you are running the MakeFeatureLayer_management command inside the for loop. This is overwriting the layer referred to by "input_gws_layer_lyr" each iteration. Here's some revised code that should fix the problem:

arcpy.MakeFeatureLayer_management(input_gws_layer, "input_gws_layer_lyr")
for period in uniqueList:
 period = int(period)
 # selection
 arcpy.SelectLayerByAttribute_management("input_gws_layer_lyr", "ADD_TO_SELECTION", "GBAUPS = %i" % period)
 arcpy.CopyFeatures_management("input_gws_layer_lyr", "input_gws_layer_lyr_%i" % period)
 #...... and the processing ......
answered Dec 10, 2013 at 19:52
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.