pjcncdb0910

Need Script For Resourcing Layer Files Directly

Discussion created by pjcncdb0910 on Apr 12, 2012
Hello ESRI User Community,

I don't post on here much, but found a situation at work that warrants some professional input.  We have a situation where we have hundreds of layer files for raster and vector datasets -- and many of them are not correctly sourced.  We need to resource the layer files for the vector datasets to an SDE connection/database.  We need to resource the layer files for the raster datasets to their respective rasters sitting within their various subdirectories within our project folder structure.

I worked with a team member to get a script written that would find all the layer files for our project.  However, for the aim just described above, I not only need a script that will find layer files -- but also automatically resource them (not just in an MXD, as that does not resource the layer file itself).  Most of the tools suggest in ArcGIS help seem to refer more to resourcing layers in a map document.

Could someone help me with a Python script that will accomplish the goal we are aiming for?  The script would have to call the layer files in a given directory, identify the dataset name that is the current sources of all these layer files, match these dataset names of the current layer file sources to same dataset names of their counterparts in the SDE database (if vector) or the appropriate subdirectory (if raster), then perform the resourcing based on this dataset name match.

I found the command "layer.ReplaceDataSource" ... but I don't think just using this one alone is going to accomplish what I need.

Thank you so much in advance for any help you can render!

Cheers and Regards,
Peter Curry

Outcomes