I figured out how to work around this. You must temporarily remove the imagery layer from the mxd object. Then apply the findAndReplaceWorkspacePaths function(s). And finally restore the imagery layer you removed. Here is some sample code that temporarily removes any layer with a name that contains "USGS EROS", changes a path, and adds the imagery layer back in.import arcpy
import os
rootdir = r"C:Your_Root_Folder"
for subdir, dirs, files in os.walk(rootdir):
for filename in files:
fullpath = os.path.join(subdir, filename)
print filename
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
# Temporarily remove the imagery layer(s)
for df in arcpy.mapping.ListDataFrames(mxd):
ImageLayerList = arcpy.mapping.ListLayers(mxd, "*USGS EROS*", df)
for lyr in ImageLayerList:
arcpy.mapping.RemoveLayer(df, lyr);
# Search-and-replace to fix up data source paths.
mxd.findAndReplaceWorkspacePaths(r"oldpath", r"newpath", False)
# Add the imagery layers back in
for lyr in ImageLayerList:
arcpy.mapping.AddLayer(df, lyr, "BOTTOM")
mxd.save()
del lyr
del df
del mxd