Updating and fixing data sources with arcpy mapping fre adult dating
To preserve these, update the data sources in Arc Map instead. The data source is changed, but (at least in the case of an SDE connection) the link is changed to a "database connection", i.e.the layer isn't being pointed to any longer, which breaks the link.import arcpy mxd = arcpy.mapping.With a little Python magic, we were able to process a whole directory tree at once by using the function.Situation: I am working on creating a Python script that will replace workspace paths for every layer in a map document in order to fix broken layers after a data migration.
What I am looking for is a way to repair multiple map documents without having to specify the name of each layer that has a broken data source.
this is very helpful, but maybe only in arcgis 9.3 While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.
I appear to be having difficulty with using 'replace Data Source'.
The script works except for when run on MXDs that have a raster dataset in them. Specifically the And Replace Workspace Path() method seems to be failing when attempting to perform the operation on the raster layer.
Code: full Path To New Workspace = r"C:\GIS\New\Data" # for context, not actually used in script full Path To Old Workspace = r"C:\GIS\Old\Data" # for context, not actually used in script mxd = arcpy.mapping. List Layers(mxd, '', df): if lyr.supports("DATASOURCE"): print Source # added to help troubleshoot And Replace Workspace Path(r"Public", r"G-DRIVE") print Source # added to help troubleshoot So the script is getting caught up on trying to And Replace Workspace Path for the raster.
Map Document(r"C:\Project\Project_SDE1.mxd") And Replace Workspace Paths(r"Database Connections\Connection to GISSDE1.sde", r"Database Connections\Connection to GISSDE2.sde") ACopy(r"C:\Project\Project_SDE2.mxd") del mxd This will remove all the red exclamation mark containing layers in the MXD and will point to the new created data source.