Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

access geom obj in arcpy.da.SearchCursor with "*" field param

$
0
0
Although I appreciate the new accessibility of fields and field methods in the da cursors in 10.1 via geometry tokens, I can't figure out how to access the geometry object when I use "*" (all) for my fields parameter. If I find the index of "Shape" and then call row[index[shapeIndex]], I get a tuple of coordinates, not the geometry object. It seems only accessible via the token "SHAPE@". I need to use the "*" field parameter because I am inserting new rows into a blank fc after reading rows from an existing with SearchCursor based on these fields, but also need to access the geometry object as input for a different function that spits out new geometry. Here is the old code below. What is the new way to write this? Thanks.

Code:

def segmentLine(ref,fc,pSegDist):
    irows = arcpy.InsertCursor(fc)
    fields = arcpy.ListFields(ref)

    rows = arcpy.SearchCursor(ref)
    for row in rows:
        feat = row.shape
        if feat.length > pSegDist:
            shapeList = segLineShapeList(feat,pSegDist)

            for pt in shapeList:
                newRow = irows.newRow()
                for f in fields:
                    if f.editable:
                        newRow.setValue(f.name,row.getValue(f.name))
                newRow.shape = pt
                irows.insertRow(newRow)
        else:
            irows.insertRow(row)
    del rows,irows


Viewing all articles
Browse latest Browse all 2485

Trending Articles