Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to create a route line based on a point layer. The existing tool does not meet the customer requirement. But using the code snippet below, the start point and end point are always the same. It means they point to the same instance? Please help. Thanks.

rows = arcpy.SearchCursor(pntLyr, whereStr, "", "", "STOPA A") 
start=True
for row in rows: 

    if (start==True):
        start_feat=row
        start=False
    else:
        end_feat=row
        # create the line based on the start_feat.shape and end_feat.shape
        # Before I reassign the start_feat, start_feat and end_feat already point to the same feature now at this point
        start_feat=row
share|improve this question

1 Answer 1

In your else block you're defining both start_feat and end_feat to be the exact same thing. Also, you want to grab row.Shape, not the entire row object.

share|improve this answer
    
The question is before I reassign the start_feat=row, it already points to the same row as the end_feat does. Or in other way, even I remove the start_feat=row in the else block, the start_feat still changes in the iterate instead it is supposed to point to the first feature –  Alex Jul 24 '13 at 19:57
    
It's still slightly confusing what you are trying to do. Are you converting all the points to a single polyline? –  Paul Jul 24 '13 at 20:00
    
The where_clause in the search cursor defines the points on a route. The field STOPA defines the sequence of the points. My problem is that the previous row (the start_feat) and the current row (the end_feat) are the same all the time even before I reassign the start_feat. –  Alex Jul 24 '13 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.