1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Updating Map Layout Pathways in ArcPy for ArcGIS Pro?

Discussion in 'Geography' started by Stefano Potter, Oct 8, 2018.

  1. I have a map which has two insets which looks like this:


    The first map frame is in the upper left and the second is all of the background. Using my exact same map layout as shown here I just want to update the pathway of a layer.

    For example, I am just trying to update one layer here, and that is the raster of Alaska shown in the upper left.

    I am trying to update the layer like this:

    #load in the map
    aprx = arcpy.mp.ArcGISProject("my_project")

    #get the first map frame
    one = aprx.listMaps[0]

    #get the layers in that frame
    one_layers = one.listLayers()

    #list all the pathways
    for layer in one_layers:

    print (layer.dataSource)

    This returns four layers which are the correct pathways for that map frame.

    I want to replace one called "/Users/user/Fall/sen.tif" to "/Users/user/Spring/sen.tif"

    I am trying to do this like so:

    aprx.updateConnectionProperties("/Users/user/Fall/sen.tif", "/Users/user/Spring/sen.tif")

    #save new layout

    I have also tried:

    one_layers[2].updateConnectionProperties("/Users/user/Fall/sen.tif", "/Users/user/Spring/sen.tif")

    where [2] is the layer location I want to replace but it is the same outcome.

    but when I load the new map the layer was not updated. My desired output is an updated layer with the same symbology as before applied.

    Login To add answer/comment

Share This Page