add one layer to another using arcpy.mp

181
0
03-27-2022 08:47 PM
AmandaYoung_95
New Contributor

So I have 3 maps in an ArcGIS Pro project. one map (colorado) has a layer called "baseball_field" but the other two maps don't have the baseball field layer. I want to add the  baseball_field layer from the colorado map to the other two maps without hardcoding their names. and the layer baseball_fieldl should not be added again to the colorado maps. 

this is what I have so far but I am getting errors...

import arcpy

aprx_path = "C:/myprojects.aprx"

aprx = arcpy.mp.ArcGISProject(aprx_path)

maps = aprx.listMaps("colorado")[0]

lyr = my_maps.listLayers("baseball_field")[0]

maps_1 = aprx.listMaps()[1:]

for m in maps_1:
lyrs = m.listLayers()

maps_1.addLayer(lyr, "BOTTOM")

aprx.saveACopy("Copy.aprx")

del aprx

 

 

0 Kudos
0 Replies