I'm trying to take an existing mxd file and update it, automatically, with an updated raster layer. The rasters are geotiffs. However, I only get errors when I try to use replaceDataSource. Here is an example call, after I've setup "lyr" to point to the correct layer in the correct dataframe of the mxd:>>> lyr.replaceDataSource("E:/Projects", "RASTER_WORKSPACE", "NewLayer_2010.tif")
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
floodlayer.replaceDataSource("E:/Projects", "RASTER_WORKSPACE", "NewLayer_2010.tif")
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 179, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\_mapping.py", line 559, in replaceDataSource
return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True)))
ValueError: Layer: Unexpected errorI have also tried using a Raster object, as returned by arcpy.Raster(filename), as the third parameter to this call, but also with no luck.I am new to map automation in ArcGIS and arcpy - is what I'm trying to do simply not possible? Or is my syntax wrong, or I'm missing a critical step?As an alternative, I also tried inserting (or adding) a new Layer (arcpy.mapping.AddLayer). This works, but requires a layer object to be added/inserted -- it wont work on a geotiff file. And I cant figure out how to make a geotiff file into a layer object automatically. I can do so interactively in the ArcMap session (Save As Layer File), but I need to automate this. Is there a way to do this automatically?Or a better way all around to do what I'm trying to do? (Update one geotiff layer in mxd with a different one, where both have same size/extent/georeference etc just different values).thanks for any tips or hints.