简体   繁体   English

arcgis union python错误

[英]arcgis union python error

Trying to loop through multiple spatial extents to create 17 unions of 4 different layers. 尝试循环遍历多个空间范围以创建包含4个不同层的17个联合。

I'm running ArcGIS Desktop 10.0, ArcInfo (advanced). 我正在运行ArcGIS Desktop 10.0,ArcInfo(高级)。

Gridnums = range(1,18)
for i in Gridnums:
    #vis6class = ws + "/" + "TVvis6class_G" + str(i)
    inList = arcpy.ListFeatureClasses("*ProcGrid_"+str(i), "")
    print "inList: " + str(inList)
    arcpy.Union_analysis([InList], ws + "/" + "TVvis6class_G" + str(i))
    print "Union completed for Grid " + str(i)
    arcpy.AddField_management(vis6class, "Object", "TEXT", 10)
    arcpy.AddField_management(vis6class, "Revert", "SHORT")
    rows = arcpy.UpdateCursor(vis6class)
    for row in rows:
        row.Revert = 0
        if row.Road == 1:
            row.Object = Road
            rows.updateRow(row)
        elif row.Water == 1:
            row.Object = Water
            rows.updateRow(row)
        elif row.Building == 1:
            row.Object = Building
            rows.updateRow(row)
        else:
            row.Object = row.Landcover
            rows.updateRow(row)

Error Code (not very helpful): 错误代码(不是很有帮助):

inList: [u'Road_ProcGrid_1', u'FPs_S_ProcGrid_1', u'er_di_ProcGrid_1', u'TV_v_ProcGrid_1'] inList:[u'Road_ProcGrid_1',u'FPs_S_ProcGrid_1',u'er_di_ProcGrid_1',u'TV_v_ProcGrid_1']

Traceback (most recent call last): File "E:\\Projects\\TV\\01_Python\\LandCover\\LC_2_Vector_Tile_6class_091312.py", line 48, in arcpy.Union_analysis([InList], ws + "/" + "TVvis6class_G" + str(i)) File "C:\\Program Files\\ArcGIS\\Desktop10.0\\arcpy\\arcpy\\analysis.py", line 483, in Union raise e RuntimeError: Object: Error in executing tool 回溯(最近一次调用最后一次):文件“E:\\ Projects \\ TV \\ 01_Python \\ LandCover \\ LC_2_Vector_Tile_6class_091312.py”,第48行,在arcpy.Union_analysis([InList],ws +“/”+“TVvis6class_G”+ str( i))文件“C:\\ Program Files \\ ArcGIS \\ Desktop10.0 \\ arcpy \\ arcpy \\ analysis.py”,第483行,在Union raise e RuntimeError:Object:执行工具时出错

I know this is programming forum over ArcGIS, but I've posted onto the esri forums as well, with lots of views but little feedback. 我知道这是ArcGIS上的编程论坛,但我也发布了esri论坛,有很多观点但反馈很少。 The tool itself runs, if I manually select each dataset for a particular extent, so the problem has to be in the coding. 如果我手动选择特定范围的每个数据集,工具本身就会运行,因此问题必须在编码中。

Thanks for any thoughts. 谢谢你的任何想法。

Rich 丰富

你有[InList]作为输入,而不是没有引号的'inList'。

According to the ArcGIS online help , the Union_analysis function requires a class as second argument, when you're passing a string. 根据ArcGIS联机帮助 ,当您传递字符串时, Union_analysis函数需要一个类作为第二个参数。 Try passing an object instead. 尝试传递一个对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM