我对Python是全新的。我试图使用arcpy.GetParameterAsText
函数将“source folder”和“geodatabase”作为ArcGIS工具箱中的输入参数。在
我真的不知道把这两个arcpy.GetParameterAsText
函数放在哪里。是否要将工作区设置为它?如果我这样做,我不知道如何创建前面没有路径的GDB文件。在
# Set the workspace
arcpy.env.workspace = "C:\\Users\\x\\Desktop\\Python_Scripting\\4\\Lesson4_Data\\Lesson4_Data"
#Create the GDB
arcpy.CreateFileGDB_management("C:\\Users\\x\\Desktop\\Python_Scripting\\4\\Lesson4_Data\\Lesson4_Data","lesson4a.gdb")
# Set the feature class variables
fclist = arcpy.ListFeatureClasses("","polygon")
fctotal = arcpy.ListFeatureClasses()
# Start the loop on all feature classes
for fc in fclist:
fcdesc = arcpy.Describe(fc)
print fcdesc.basename + " is currently importing into the lesson4a.gdb."
arcpy.CopyFeatures_management (fc, "C:\\Users\\x\\Desktop\\Python_Scripting\\4\\Lesson4_Data\\Lesson4_Data\\lesson4a.gdb\\" + fcdesc.basename)
print fcdesc.basename + " is done importing into the lesson4a.gdb.\n"
arcpy.GetParameterAsText(#)
函数将从ArcGIS工具读取输入参数。在在编写脚本和调试期间,最简单的方法是硬编码函数的输入变量,以验证函数是否正常工作。一旦工具(本质上)是您想要的方式,在ArcMap中创建工具箱和脚本工具。在
要接受来自工具执行对话框的输入参数,您需要在创建脚本工具时创建它们(并更改代码以接受
GetParameterAsText
输入)。最好的演练是ArcGIS资源中心。在在Python脚本中,我通常首先读取输入参数,这样,它们就可以作为脚本其余部分的变量使用。索引值指示哪个参数是哪个。在
相关问题 更多 >
编程相关推荐