3

When using a cursor to loop through an attribute table, is it possible to iteratively select each row?

I want to clip a line to a polygon grid (see previous question); due to the size of the grid the split function fails. Hence I'm interested in selecting each polygon, and clipping the line to the selected cell by using the shapefile with only that cell selected.

I'm familiar with looping through the attribute table and performing calculations - but I don't know how to select a row.

asked Aug 17, 2011 at 14:47

1 Answer 1

5

Yes, use SelectLayerByAttribute_management() and select by FID.

answered Aug 17, 2011 at 14:56
4
  • You got ahead of me! Commented Aug 17, 2011 at 14:57
  • It would probably be faster to build a list of OIDs and do one Select by Attribute at the end rather than within the cursor. This won't work on Oracle if you have more than 1000 OIDs to select though (see this question). Commented Aug 17, 2011 at 18:25
  • @blah238, the specific workflow that the OP is talking about involves selecting one OID at a time. Would this speed up that process? Commented Aug 17, 2011 at 18:42
  • 1
    I see what you mean -- instead of selecting the feature and then calling clip, you could use the shape field (geometry object) of the current row as the clip features argument to the clip command. Might be a little faster. Commented Aug 17, 2011 at 21:03

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.