Sunday 19 August 2018

arcpy - Auto-updating symbology between *.mxds for same shapefile using arcgisscripting?


I have a variety of .mxds for any one project I'm working on, which are all different but all use the same set of base shapefiles for my project.


I know I can save a .lyr version of my initial shapefile and import this into subsequent .mxds to retain the original symbology I have set, but if I then change the symbology of the original shapefile, even if I save over the .lyr file with the new symbology, nothing updates in any of my existing files?


My question is, is there an easy way to auto-update this symbology, or is it a manual task? If it's a case of manual re-linking then that's a lot of updating I'm going to have to do on a routine basis - so I'm keen to find a simple way of doing this? I have no python experience but if this is the way to do it then I am eager to learn!!



In terms of what I have found so far for a Python solution:


I found this link here on StackExchange, which I think might be a good starting point in terms of Python, as it seems to be a script to auto-update data sources [ How to update shapefile data source in multiple dataframes and mxds using lyr.replaceDataSource and Python dictionary? ]


And also I found this thread on ArcGIS Idea [ http://ideas.arcgis.com/ideaView?id=087300000008FNBAA2 ] albeit dated 2010, which seems to ask the same question as me, and someone has provided a link to some arcpy.mapping sample scripts which again look very similar to what I need, though they seem to do one .mxd at a time which is about the same effort as relinking them manually.


I did download the sample python scripts to have a look at, and I've installed Python (command line), but I have no experience with this and am struggling a bit with knowing where to start to get these to run!


I'm not sure if there's a simpler way of going about this which AUTO links rather than re-running a script with every edit - it seems odd to me that this is not a function built in to ArcGIS?


I am using ArcMap 9.2



Answer



If you upgrade to ArcGIS 10.1 or 10.2 you should be able to do this using a Python AddIn Extension.


There is an AddBaseLayer example on this page that shows how.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...