floydfan

Layer.replaceDataSource

Discussion created by floydfan on Sep 27, 2012
Latest reply on Sep 10, 2014 by yaron148
Hi,
I'm trying to change layer data source from one shape file to another in different workspace (directory).

mxd = arcpy.mapping.MapDocument(r"Z:\02_GIS\Project\mxd\P01.mxd")
print "mxd"
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyrfile = arcpy.mapping.Layer(r"Z:\Maps\GIS_utilities\python_script\lyr\_kabel.lyr")
print lyrfile.workspacePath # old path
lyrfile.replaceDataSource(r"Z:\02_GIS\Project\wektor", "SHAPEFILE_WORKSPACE", "P01_RIVER.shp")


But this way its not working. What should I change?

Thanks form help,
MF

Outcomes