1

私はArcMapに取り組んでおり、このpythonコードを持っています:

import arcpy, sys

feature = arcpy.GetParameterAsText(0)


def nearRoutine():
    #calculate the distances using the current dataset
    arcpy.Near_analysis(feature, feature)

    #iterate through any features which are within the distance
    cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
    row1 = cur.next()
    while row1:

        #this point is within the distance of its neighbor, so delete it
        cur.deleteRow(row1)

        #now re-run this routine on the new dataset
        del row1, cur
        nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()

私のエラーメッセージ: UnboundLocalError: 代入前に参照されたローカル変数 'row1'

変数が明確に定義されているため、わかりません...

誰かが問題を抱えていますか?

4

1 に答える 1

1

削除row1してから、それを要求する (チェックする) ことを繰り返します。

del変数row1または変数がある場所で本当に使用する必要があるかどうかはわかりませんcur。データ構造の内容ではなく、これらの変数を削除しています。

于 2013-08-13T16:58:41.913 に答える