There are two approaches in applying a layer file to a data set either load the layer file directly or load the data set first and then apply the layer file to the data set. In the past, we had run into problems loading the layer files directly where some properties would not get set (especially label properties) so we decided to go with the second option where we would load a data set and apply a layer file. The main difference is that in the first case the layer file cannot have any broken links while the second method does not care about broken links.
At ArcGIS 10.1 however, this approach stopped working. RegGSS uses close to 800 layers files and checking/fixing each one by hand would have been a monumental task in both effort and time. Our solution was to created a C# script to check every layer file for broken links and repair those that were broken or flag them as not-repairable so they could be repaired manually. The general logic is as follows:
- Cycle through all layer files used by RegGSS one at a time and check if the layer file is valid or not by using the Valid property on the ILayer interface of ArcObjects
- If layer file is not valid, read the SDE server name, reset the connection parameters and re-save the layer file.
- Re-check the validity of the re-saved layer file and if it still has a broken link, write out the layer file name to a text file so it can be fixed manually.
You can check out the main procedures here on GitHub.
Carlos Piccirillo, Senior Geographer, Regulation GIS, SFWMD
Juan Tobar, Supervising Geographer, Regulation GIS, SFWMD