I'm using ArcGIS 10.3. I have an MXD that contains symbolized global raster images. I have a GP tool that masks these rasters to a country or state and exports the images. I'm trying to update the source background layers and rasters each time a new country is chosen. The layer names are all generic, but the source files all have the country or state name tagged on. findAndReplaceWorkspacePath works just fine with the background layers (shapefiles), but it won't update the rasters. I've confirmed the old and new sources with print statements, it's just not changing the source. The only time I get images is if I use the default state (Texas) set in the MXD. If I choose any other location, I just get a blank country or state outline image.
Here is my code snippet:
layer_list = ["Precip","High_Temp","Temp_Departure"] for filename in layer_list: layer_name = filename for lyr in arcpy.mapping.ListLayers(mxd): if lyr.supports("DATASOURCE"): if layer_name == str(lyr.name): old_source = os.path.dirname(lyr.dataSource) new_source = country_temp_path lyr.findAndReplaceWorkspacePath(old_source, new_source, False)