我有个错误
Failed to execute: Input Table: Parameters are not valid. ERROR 000732: Input Table: dataset mytable does not exist or is not supported Failed to execute (AddField).
import arcpy, os, sys, traceback
arcpy.env.workspace = "L:\\school\\GEO614\\PythonPrimer\\Chapter06\\Data\\cursors.gdb"
arcpy.env.overwriteOutput = True
outpath = "L:\\school\\GEO614\\PythonPrimer\\Chapter06\\MyData\\exercise6.gdb"
outname = 'mytable'
arcpy.CreateTable_management(outpath, outname)
arcpy.AddField_management(outname, 'LakeFC_ID', 'SHORT')
arcpy.AddField_management(outname, 'Lake_Name', 'TEXT', '50')
arcpy.AddField_management(outname, 'Lake_Info_ID', 'LONG')
arcpy.AddField_management(outname, 'Lake_Temp', 'SHORT')
我不知道我的代码有什么问题。在
这是因为您将工作区设置为与outpath中包含的GDB不同的GDB。因此,它在outpath指定的GDB中创建表,但由于随后只向add field工具提供表名,add field工具将在您设置为工作区的GDB中查找,并且找不到该表。 使工作区和输出路径相同,或者只提供arcpy.env.工作区作为CreateTable工具的第一个参数,或者使用os.path.join操作系统并将其提供给Add Field工具,它将正常工作。在
对于arcpy用户来说,000732似乎还有很多其他原因,如果您试图利用用户输入文件路径并将字符串变量与它们连接起来,经过数小时的在线搜索,这个解决方案帮助了我:
https://gis.stackexchange.com/questions/32064/getting-full-path-of-layer-selected-in-drop-down-box-for-arcgis-python-script-to
相关问题 更多 >
编程相关推荐