laptop and a wrench

漏洞

The Map.addLayer command fails with ValueError when attempting to add a layer created with the MakeFeatureLayer_management and MakeRasterLayer_management tools.

上次发布: February 24, 2020 ArcGIS Pro
漏洞 ID 编号 BUG-000125587
已提交September 26, 2019
上次修改时间June 5, 2024
适用范围ArcGIS Pro
找到的版本2.4.1
操作系统Windows OS
操作系统版本10.0
状态As Designed

附加信息

The MakeFeatureLayer_management tool does not return a layer object but instead a result object. Extract the layer from the result using the appropriate index. In this case, it is [0]. The object at index 0 in the result object is the layer to add. Use the following code: temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0] p = arcpy.mp.ArcGISProject('current') m = p.listMaps('Map')[0] m.addLayer(temp)

解决办法

The object at index 0 in the result object is the layer to add Use the following code:

temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0]

p = arcpy.mp.ArcGISProject('current')

m = p.listMaps('Map')[0]

m.addLayer(temp)

重现步骤

漏洞 ID: BUG-000125587

软件:

  • ArcGIS Pro

当漏洞状态发生变化时获得通知

下载 Esri 支持应用程序

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项