私の指示を選択層を使用していくつかの問題を持つ:は場所の構文で
- ワークスペース ためのユーザー入力を取得
- を開始します以下
Create a Python script that selects parcels from "coa_parcels.shp" that intersect with the shapefile "floodplains.shp" and creates a new shapefile that only contains the selected parcels.
The location of the workspace and the three shapefiles (coa_parcels, floodplains, and the output) should be treated as user-defined inputs using "raw_input" statements.
は、この部分のためのスクリプトのための擬似コードは一例です
- 入力フィーチャクラス名(例:coa_parcels.shp)のユーザ入力を取得
- 選択フィーチャクラス名(例:出力フィーチャクラス名のfloodplains.shp)
- ゲットユーザー入力(例えばselected_parcels.shp)は
- は、ワークスペースを設定し、出力設定を上書き
- に基づいて、場所によって層からの一時的な機能層
- 選択を作成します。選択機能クラス
- コピー新しいフィーチャクラス
- 印刷ユーザーをさせるメッセージに選択した機能新しいフィーチャクラスが作成されたことを知っている
- エンド
マイスクリプト:
import arcpy
workSpace = raw_input("What is the workspace location? ")
inFeature = raw_input("What is the input feature class name? ")
selFeature = raw_input("What is the select feature class name? ")
outFeature = raw_input("What is the output feature class name? ")
arcpy.env.workspace = workSpace
arcpy.env.overwriteOutput = True
arcpy.MakeFeatureLayer_management("coa_parcels.shp", "lyr")
arcpy.SelectLayerByLocation_management(coa_parcels.shp,"INTERSECT",floodplains.shp, "NEW_SELECTION")
arcpy.CopyFeatures_management("lyr", "selected_parcels")
print "A new feature class",outFeature,"has been created!"here
私のエラーはこれです:NameError:名 'coa_parcels' が
"name 'coa_parcels'が定義されていません"は自明です。他の出現を見ると、おそらく識別子ではなく文字列でなければなりません(=あなたは引用符を忘れてしまいます)。 –