我已經創建了一個從ArcMap 10.1會話運行的python腳本;不過,如果可能的話,我想修改它作爲獨立腳本運行。問題是我沒有看到在ArcMap外部執行時提示用戶輸入參數的解決方法。如何使用arcpy.GetParameterAsText作爲獨立腳本運行時更改python腳本?
這可以合理地完成嗎?如果是這樣,我將如何處理它?以下是我的腳本示例。我怎樣才能修改這個命令來提示用戶在命令行輸入參數0和1的路徑名?
import arcpy
arcpy.env.overwriteOutput = True
siteArea = arcpy.GetParameterAsText(0)
tempGDB_Dir = arcpy.GetParameterAsText(1)
tempGDB = tempGDB_Dir + "\\tempGDB.gdb"
# Data from which records will be extracted
redWoods = "D:\\Data\\GIS\\Landforms\\Tress.gdb\\Redwoods"
# List of tree names that will be used in join
treesOfInterest = "C:\\Data\\GIS\\Trees\\RedwoodList.dbf"
inFeature = [redWoods, siteArea]
tempFC = tempGDB_Dir + "\\TempFC"
tempFC_Layer = "TempFC_Layer"
output_dbf = tempGDB_Dir + "\\Output.dbf"
# Make a temporaty geodatabase
arcpy.CreateFileGDB_management(tempGDB_Dir, "tempGDB.gdb")
# Intersect trees with site area
arcpy.Intersect_analysis([redWoods, siteArea], tempFC, "ALL", "", "INPUT")
# Make a temporary feature layer of the results
arcpy.MakeFeatureLayer_management(tempFC, tempFC_Layer)
# Join redwoods data layer to list of trees
arcpy.AddJoin_management(tempFC_Layer, "TreeID", treesOfInterest, "TreeID", "KEEP_COMMON")
# Frequency analysis - keeps only distinct species values
arcpy.Frequency_analysis(tempFC_Layer, output_dbf, "tempFC.TreeID;tempFC.TreeID", "")
# Delete temporary files
arcpy.Delete_management(tempFC_Layer)
arcpy.Delete_management(tempGDB)
這是一個哲學問題,因爲它是一個程序化的問題。我對這是否可以完成以及這樣做的努力量感興趣。是否值得方便的不打開地圖文件?
即使只有必需的參數,我也會得到該錯誤。 –