2017-06-08 9 views
-1

インストラクターのコードがありますが、モデラーのスクリプトとして実行するとエラーが発生します。 コードの一部ですが、残りは繰り返しますが、DISTフィールドの値は異なります。 このコードは、フィーチャクラスに "DIST"フィールドを追加し、UpdateCursorの条件に基づいてフィーチャクラスを埋め込むことを目的としています。カーソルをarcpyで更新し、値を入力してください

#Import arcpy and standard library modules 
import arcpy, sys, os 

# Get feature class from argument 
zoneArcSelect = sys.argv[1] 

# Add DIST field to input feature class 
arcpy.AddField_management(zoneArcSelect, "DIST", "SHORT") 

#get rows using update cursor and conflict selection 
rows = arcpy.UpdateCursor(zoneArcSelect,"(LZONE = 'O-L' AND RZONE = 'M-1') OR (RZONE = 'O-L' AND LZONE = 'M-1')") 

# calculate value for DIST and update row 
for row in rows: 
    row.DIST = 100 
    rows.updateRow(row) 

#get rows using update cursor and conflict selection 
rows = arcpy.UpdateCursor(zoneArcSelect,"(LZONE = 'M-1' AND RZONE = 'RPC') OR (RZONE = 'M-1' AND LZONE = 'RPC')") 

# calculate value for DIST and update row 
for row in rows: 
    row.DIST = 200 
    rows.updateRow(row) 

#get rows using update cursor and conflict selection 
rows = arcpy.UpdateCursor(zoneArcSelect,"(LZONE = 'M-1' AND RZONE = 'RM-1') OR (RZONE = 'M-1' AND LZONE = 'RM-1')") 

# calculate value for DIST and update row 
for row in rows: 
    row.DIST = 200 
    rows.updateRow(row) 
+1

質問の回答方法については、[guidelines](https://stackoverflow.com/help/mcve)の形式に従ってください。 – user3382203

+0

生成されるエラーは何ですか? Arc 10.1以降を使用していますか? – Erica

+0

構文エラーです。バージョン10.3私は信じている – deakin1416

答えて

0

モデラーでaddFieldツールを使用したときに、LZONEとRZONEというコードを使用しなかったというのは自分の責任ではありませんでした。だから問題の原因となったコードと一致しませんでした。

関連する問題