Here’s one way forward utilizing ArcGIS for Desktop and Python….
Working at Esri Australia in the Support and Training realm, we listen to numerous client’s requests, concerns and workflow issues. To keep abreast of how our technology is heading, one source I frequent is the ArcUser magazine published with tutorials, tips and articles on best practise. In the Winter 2015 edition of ArcUser, there was an article about “Creating a Python Tool That Summarises ArcMap Layer Properties”. By no means is this article to take credit for this innovative post, but more to suggest how each and every ArcUser can adopt and enhance such functionality.
From this, I quickly knocked up some python script that made good use of arcpy.mapping classes and functions to return a useful summary of layer properties within each MXD that is entered as input. For each layer, the following list of properties [mxdpath, layer.longName, layer.description, layer.dataSource, mxd.author, mxd.dateSaved] was then written to a CSV output (see Figure 1 for exact python syntax guidance).
Figure 1. Excerpt of the functional logic returning layer properties within the python source file “MXD_layer_properties.py”
Once I tested and returned a list of layer properties, I wanted to share this functionality with all my ArcGIS users, so I created a script tool from this (a great reference to do this is here: http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/a-quick-tour-of-creating-tools-in-python.htm), where Figure 2 shows the result of this script tool, a familiar geoprocessing tool dialog box.
Figure 2. Dialog box of the script tool “MXD Layer Properties saved to (3) optional CSV outputs”
If you are wondering why the script tool (as seen in Figure 2) has two optional inputs, MXD Directory Path OR MXD Single Path – it’s always a good idea to create your workflows considering how your users might want to use your script tool – this conditional functionality (where the code is shown in Figure 3) allows the user to return layer properties within many or simply an individual map document.
Figure 3. Excerpt of the conditional logic for input workspace within the python source file “MXD_layer_properties.py”
With the majority of the hard work complete (that being a tested python script and script tool created), I wanted to further enhance this to include two more separate CSV optional outputs returning layer symbology (e.g. [layer.showLabels, layer.symbologyType, layer.symbology.valueField] and layer properties of my service layers (e.g. layer.serviceProperties). The serviceProperties of any layer provides access to connection information for ArcSDE and/or web service layers. The returned results are dictionary key-value pairs, providing very useful information such as service type, server name, database, username and version for any ArcSDE layer; and for web services, important dictionary keys can be returned such as the service type, URL and service name.
My interpretation of the ‘why’ behind returning such large scale information is in gaining valuable insight as to each ArcGIS user’s interpretation and spatial analysis of each map document layer that is conveyed to their intended audience.
It only takes a matter of seconds to run the script tool “MXD Layer Properties saved to (3) optional CSV outputs” (provide below), where Figure 4 shows it is possible to view the completed layer property output in either ArcMap or another text editor, such as Notepad++.
Figure 4. CSV Output of the script tool “MXD Layer Properties saved to (3) optional CSV outputs”.
For those interested, I can email you a zip file comprising the script tool, source python file and three CSV optional inputs – my correspondence email is firstname.lastname@example.org. If you wanted to adopt and enhance such a script for your own value added workflows, why not take a look at the alphabetical list of the many arcpy.mapping classes and functions:
Alphabetical list of arcpy.mapping classes:
Alphabetical list of arcpy.mapping functions:
Happy coding and enjoy utilising arcpy classes and functions!
Thanks for your time in reading this article,
The following are useful links for your consideration:
What is the ArcUser? http://www.esri.com/esri-news/arcuser/what-is
Python courses available for you to consider: https://esriaustraliatechblog.wordpress.com/2014/08/01/wondering-how-to-use-python-with-arcgis-esri-australia-have-courses-that-can-help/