Is it possible to update the source of a layer within an mxd using arcpy mapping?

260
2
Jump to solution
09-04-2017 10:02 AM
RichardGeoghegan2
New Contributor II

I have an mxd which contains a layer (in shapefile format).

I wish to update the path of the shapefile to the path of another shapefile by using a stand alone script.

Is this possible? 

I have used arcpy.mapping.AddLayer to find my layer.

I wonder if I can now use .replaceDataSource to update the source of the layer in the mxd?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor

Did you try it and it didn't work?

Not sure what the problem is unless you don't have the files anymore to try.

Look at UpdataLayer which essentially does a remove and add

replaceDatasource etc 

View solution in original post

2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Did you try it and it didn't work?

Not sure what the problem is unless you don't have the files anymore to try.

Look at UpdataLayer which essentially does a remove and add

replaceDatasource etc 

RebeccaStrauch__GISP
MVP Esteemed Contributor

You can also check to see if any of the tools in my addin will work.  I mainly works on broken links but can be adapted to work with any.

/blogs/myAlaskaGIS/2015/08/31/python-addin-for-data-inventory-and-broken-link-repair?sr=search&searc...