laptop and a wrench

Bug

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

Last Published: February 24, 2020 ArcGIS Pro
Bug ID Number BUG-000125587
SubmittedSeptember 26, 2019
Last ModifiedJune 5, 2024
Applies toArcGIS Pro
Version found2.4.1
Operating SystemWindows OS
Operating System Version10.0
StatusAs Designed

Additional Information

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)

Workaround

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)

Steps to Reproduce

Bug ID: BUG-000125587

Software:

  • ArcGIS Pro

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options